Next.js Discord

Discord Forum

Form Action State Error Handling

Unanswered
Turkish Angora posted this in #help-forum
Open in Discord
Turkish AngoraOP
The app docs say to handle expected errors by returning an object with a string prop to consume the error in the UI:

export async function test() {
  return { error: "test" };
}


But I'm switching to a toasting system, and I was wondering if I could handle server actions that return an error message globally instead of inside each form component.

1 Reply

Turkish AngoraOP
I guess the best solution is to wrap all of my server actions?