Next.js Discord

Discord Forum

React Hook form with server actions, useActionState(formerly useFormState)

Unanswered
WebDevSayantan posted this in #help-forum
Open in Discord
Is there any best practices or definitive guide on how I can use React hook form with a Next.js 14 app. I'm using Zod for validation. Want I want is to integrate this setup with useActionState to manage loading state.

6 Replies

you can check this video ,
its react hook form + server actions + zod, doing client and server validations
https://www.youtube.com/watch?v=VLk45JBe8L8
Masai Lion
Here is your safe zone. https://next-safe-action.dev
@WebDevSayantan Is there any best practices or definitive guide on how I can use React hook form with a Next.js 14 app. I'm using Zod for validation. Want I want is to integrate this setup with useActionState to manage loading state.
Personally, I have not found a better solution than shadcn's form integrated with react-hook-form and next-safe-action, you get everything you could want, client-side validation, server-side validation, loading state, accessibility. It is by far the best DX and UX I've had with forms.
Masai Lion
@Ocicat I was thinking the same combo. Do you have some where sample implementation?
Yeah look at the next-safe-action documentation for integration with react-hook-form it links to a sample repo