#How to use `zod` validation in ShadcnUI when I use server action?

4 messages · Page 1 of 1 (latest)

odd seal
#

I use shadcn-ui to create UI Components and also use react-hook-form and zod following shadcn-ui documentation, but I can't use the onSubmit prop in the Form component because I use the action prop and passing the Server Action function.

dusk zephyr
#

I have recently built a form using ShadcnUI and react-hook-forms.

Mind sharing a code snippet to see if I can help out?

odd seal
#

Thanks... for your reaponse. I decide to use client side validation only and send the request to the next API.

But if you have any advice and if it's possible to combine Client Component and Server Component doing realtime validation, it's will really help me...

dusk zephyr
#

I'll have to go through me notes and get back go you 🤣

But I have a sneaking suspicion in my example I actually sent data to a route handler and did the server side validation there with zod.