Im just trying to understand the use case for using the react hook useForm over the react-dom useFormState. I see in the Nextjs docs that they recommend using the built in useFormState, but when I see people build apps with the new version of Nextjs a lot of them use the react hook useForm.
Im trying to understand the benefit of both. I do notice that some validate on both ends client and server side when using useForm with zod, but it seems like with the use of useFormState and just validating on the server is easier and produces the same result.
2
Answers
I can’t tell you anything about
useForm
. ButuseFormState
has only one purpose. Provide information (return value) from form actions (Next.js Server Actions). This is handy for example if you mutate server state and want access feedback (results) from the server action.