Installation
To use Conform, you need to install it along with the schema library you want to support.
#Zod
If you are using Zod, install the validation helper library that supports Zod schemas.
npm install @conform-to/react @conform-to/zod zodTo validate FormData, use parseWithZod.
import { useForm } from '@conform-to/react';
import { parseWithZod } from '@conform-to/zod';
import { z } from 'zod';
const schema = z.object({
email: z.string(),
password: z.string(),
});
function ExampleForm() {
const [form, { email, password }] = useForm({
onValidate({ formData }) {
return parseWithZod(formData, {
schema,
});
},
});
// ...
}Zod v3 vs v4
The default import @conform-to/zod is designed for Zod v3. If you're using Zod v4, use the dedicated subpath export instead:
// Zod v3
import { parseWithZod } from '@conform-to/zod';
import { z } from 'zod';
// Zod v4
import { parseWithZod } from '@conform-to/zod/v4';
import { z } from 'zod/v4'; // or 'zod/v4-mini'#Valibot
If you are using Valibot, install the validation helper library that supports Valibot schemas.
npm install @conform-to/react @conform-to/valibot valibotTo validate FormData, use parseWithValibot.
import { useForm } from '@conform-to/react';
import { parseWithValibot } from '@conform-to/valibot';
import { object, string } from 'valibot';
const schema = object({
email: string(),
password: string(),
});
function ExampleForm() {
const [form, { email, password }] = useForm({
onValidate({ formData }) {
return parseWithValibot(formData, {
schema,
});
},
});
// ...
}#Yup
If you are using Yup, install the validation helper library that supports Yup schemas.
npm install @conform-to/react @conform-to/yup yupTo validate FormData, use parseWithYup.
import { useForm } from '@conform-to/react';
import { parseWithYup } from '@conform-to/yup';
import * as yup from 'yup';
const schema = yup.object({
email: yup.string(),
password: yup.string(),
});
function ExampleForm() {
const [form, { email, password }] = useForm({
onValidate({ formData }) {
return parseWithYup(formData, {
schema,
});
},
});
// ...
}