Skip to content

react-hook-form

Use when building forms in React with React Hook Form — registration, validation, error handling, or complex multi-step forms. Also use when integrating forms with Zod, shadcn/ui, or server actions.

ModelSource
sonnetpack: forms
Full Reference

┏━ 🔧 react-hook-form ━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ Use when building forms in React with React Ho… ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

React Hook Form v7.71+ is a performant, uncontrolled forms library for React. It minimizes re-renders by keeping inputs uncontrolled by default, integrates with Zod via @hookform/resolvers for type-safe validation, and provides Controller for external UI libraries that don’t expose a native ref. FormProvider enables context-driven multi-step forms without prop drilling.

ItemValue
Installnpm i react-hook-form @hookform/resolvers zod
Core hookuseForm<T>({ resolver, defaultValues, mode })
Zod resolverzodResolver(schema) from @hookform/resolvers/zod
TypeScript requirementv4.9+
Docshttps://react-hook-form.com
I want to…File
Set up a basic form, configure useForm, and use the register APIreference/setup.md
Add Zod validation, conditional rules, or file validationreference/validation.md
Display field errors, server errors, and error summariesreference/error-display.md
Use Controller or useController with shadcn/ui or server actionsreference/controlled-inputs.md
Build dynamic arrays with useFieldArray and tune performancereference/field-registration.md
Build multi-step forms with FormProvider and per-step validationreference/multi-step.md

Usage: Read the reference file matching your current task from the index above. Each file is self-contained with code examples and inline gotchas.