I'm using server actions directly as form actions in my project to benefit from progressive enhancement (i.e. the form works even without having JavaScript enabled). In this sort of a use case, what best practices are there for throwing and catching errors from the Server Action? For example, input validation errors.
- I was initially thinking of error boundaries, but it seems that you can't really really include any information in the errors, as those are stripped out in prod
- Another thought I had was redirecting back to the form, but with query parameters that indicate the error (e.g.
?error=noEmail) - Finally, I thought about returning data from the action, but as far as I know there's no way to consume this data without running JS on the client and calling the server action that way
Are there any best practices around this? Anyone handled a similar case in their project?