
Conform Has a Free Type-Safe Form Library — Here's How to Use It
Server-side form validation that matches client-side validation — without duplicating logic. Conform bridges the gap with progressive enhancement and type-safe schemas. What Is Conform? Conform is a type-safe form validation library for React, built for progressive enhancement. It works with Remix, Next.js, and any React framework — validating on both client and server using the same schema. Quick Start npm install @conform-to/react @conform-to/zod zod import { useForm } from ' @conform-to/react ' ; import { parseWithZod } from ' @conform-to/zod ' ; import { z } from ' zod ' ; const schema = z . object ({ email : z . string (). email ( ' Invalid email ' ), password : z . string (). min ( 8 , ' At least 8 characters ' ), }); export function LoginForm () { const [ form , fields ] = useForm ({ onValidate ({ formData }) { return parseWithZod ( formData , { schema }); }, shouldValidate : ' onBlur ' , }); return ( < form id = { form . id } onSubmit = { form . onSubmit } noValidate > < div >
Continue reading on Dev.to React
Opens in a new tab

