Which form validation library should we use #35
Replies: 1 comment 1 reply
-
In NextJS 13, they have something called server actions and instead of using event handlers to submit the form and process the data, they are now suggesting to use server actions. Found a video - Lee Robinson - Next.js Metamorphosis, React Summit 2023 where Lee shares why Vercel made this shift to App Router. It's a good one. But, around 18.47 mins, he starts to refactor code from 'old' NextJS to NextJS 13 and uses Server Actions instead of event handler to handle form data at server side. Also, if you read the NextJS 13 Docs, using Server Actions will opt into running the React //next.config.js
module.exports = {
experimental: {
serverActions: true,
},
} The data passed to a Server Action can be validated or sanitized before invoking the action. For example, you can create a wrapper function that receives the action as its argument, and returns a function that invokes the action if it's valid. You could read about it - here |
Beta Was this translation helpful? Give feedback.
-
Right now, React-Hook-Form seems to be in the lead.
Are there any arguments for Formik?
Are there any other better libraries?
3 votes ·
Beta Was this translation helpful? Give feedback.
All reactions