I had a task where I needed to validate a sign-up form in React.
There was a name, email, password, confirm password, and a checkbox. All fields were required and the password had a couple of rules.
I got it to work using Formik + Yup, was that overkill for this use-case?
I found that there are a ton of form validation libraries, which one should I work with? What makes one better than the other?
Top comments (7)
I personally always use formik. It's battle tested, and can support several different form types.
Even for simple forms I like formik because as the application grows I have already set up some patterns.
I think I have an idea for my next opinionated piece! π
Awesome! π
I've never used it but I've seen some great things from react-hook-form! The owner of the repo is really on top of things and I think it has one of the smallest (if not the smallest?) bundle sizes for form validation libraries out there.
IMO, it is overkill. I think Formik + Yup is great when your app is heavily form based. If thatβs your only use case, youβll be fine with a custom solution π
Makes sense, thanks Thomas!
Formik and yup are a great pair. Although it does seem like you have a somewhat basic use case, and you can probably rely on basic HTML form validation.
I'll check out other solutions. Thanks Dor!