I need to pick a validation library for my frontend project and I’m stuck between Joi and Yup. After doing some research, I found out that Joi performs faster but Yup has a much smaller bundle size (about 2.5 times lighter). People say Joi works better for server-side stuff while Yup was made specifically for client-side validation. I also read that Joi might have some issues when used in browsers, but I can’t figure out exactly what those problems are. Has anyone used both libraries? What specific limitations does Joi have on the frontend that Yup doesn’t? I’m trying to decide if the performance boost from Joi is worth the extra bundle weight, or if I should just go with Yup since it’s designed for frontend use.
Interesting dilemma! What kind of forms are you building? Simple contact forms or something more complex with nested validation? And what’s your target bundle size? That 2.5x difference could be massive depending on your constraints
I’ve used both on tons of projects. Joi’s a pain in browsers because it relies heavily on Node.js modules that need polyfills or special bundler setup. This makes builds more complex and can break things at runtime if you mess up the config. Yup was built for browsers from day one, so it just works without the headaches. Performance-wise, they’re basically the same once you account for Joi’s bigger bundle size. Unless you’re doing crazy complex validation with thousands of simultaneous checks, Yup’s fast enough. Plus Yup plays way nicer with frontend stuff - especially form libraries like Formik or React Hook Form.
Honestly, just go with yup. I’ve been down this road before and joi’s browser issues aren’t worth the headache. The performance difference is negligible for most use cases, and yup’s API feels more intuitive for frontend work IMO. Bundle size matters more than you think, especially on mobile.