Next.js Discord

Discord Forum

SSR form validation with client side result

Answered
Honzosaurus_3.1415926535 posted this in #help-forum
Open in Discord
Hey everyone, if I have a form that has a server action that may return a message saying what is wrong with the data provided in the form (eg. an already used email), how do I display the message on the client side from the server side without a url search parameter?

14 Replies

American Chinchilla
@Honzosaurus_3.1415926535 could you give an example of what you mean?
At least from what i understand you want to display error related to each form field?
American Chinchilla
You could use something like zod
And reach hook form
@Honzosaurus_3.1415926535 cookies can be used in that case if you don't want query params in the url
American Chinchilla
The react hook form handle the client form validation and has some other built in properties u could use, zod can be used on backend for more robust checking and client side (it integrates with react hook form)
so basically you want to pass some data from server to the client without using query param in the url, right?
yeah, you can use cookie instead
I'm asking mainly for the most used way of achiving ssr form validation with the result displayed on the client side
Answer
this is the most used & loved library
@James4u https://next-safe-action.dev/
Alright, thanks a lot, I'll look at it