Standard schema validation
Validate submitted form data against a Zod or Valibot schema while retaining inferred form types.
Conform · Const
Pass a Standard Schema-compatible schema as the first useForm argument to enable validation and schema-derived type inference. Conform validates it before onValidate and exposes the parsed result through ctx.schemaValue when successful.
Schema integration lets useForm accept a Standard Schema-compatible schema as its first argument. Conform validates with that schema before onValidate, exposes the parsed result through ctx.schemaValue after success, and forwards schemaOptions to the configured validator.
useForm(schema, options)| Name | Type | Description |
|---|---|---|
schema | Schema | A Standard Schema-compatible validation schema used for validation and type inference. |
options | UseFormOptions | Configuration for the form, including optional schemaOptions forwarded to the validator. |
A form and field metadata tuple from useForm, with schema validation and schema-derived type inference enabled.
import { useForm } from '@conform-to/react';
import { z } from 'zod';
const schema = z.object({
email: z.string().email(),
});
export function SignupForm() {
const [form, fields] = useForm(schema);
return (
<form {...form.props}>
<input {...fields.email.props} />
</form>
);
}Pass the schema as the first argument to useForm so Conform can validate against it and infer schema-derived types.
Validate submitted form data against a Zod or Valibot schema while retaining inferred form types.
Read the parsed, successfully validated value during validation handling.
Forward validator-specific configuration without manually invoking the schema library.
useForm accepts a Standard Schema-compatible library when the schema is supplied as its first argument. This enables schema validation and schema-derived type inference.
Follow-up: How can another schema system be supported? Use configureForms with custom isSchema and validateSchema functions.
Conform runs schema validation before onValidate. The callback can then add new errors or replace the errors produced by schema validation.
Follow-up: What happens after successful parsing? The parsed value is available as ctx.schemaValue during validation handling.
schemaOptions are forwarded to the configured schema validator when useForm(schema, options) is used. This allows validator-specific configuration without changing the schema itself.
Follow-up: What if the schema library is not Standard Schema-compatible? Configure a customized form hook with configureForms.
useFormschemaOptionsonValidatectx.schemaValueconfigureFormsStandard Schema