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.
| Model | Source |
|---|---|
| sonnet | pack: forms |
Full Reference
┏━ 🔧 react-hook-form ━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ Use when building forms in React with React Ho… ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
React Hook Form
Section titled “React Hook Form”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.
Quick Reference
Section titled “Quick Reference”| Item | Value |
|---|---|
| Install | npm i react-hook-form @hookform/resolvers zod |
| Core hook | useForm<T>({ resolver, defaultValues, mode }) |
| Zod resolver | zodResolver(schema) from @hookform/resolvers/zod |
| TypeScript requirement | v4.9+ |
| Docs | https://react-hook-form.com |
Reference Index
Section titled “Reference Index”| I want to… | File |
|---|---|
| Set up a basic form, configure useForm, and use the register API | reference/setup.md |
| Add Zod validation, conditional rules, or file validation | reference/validation.md |
| Display field errors, server errors, and error summaries | reference/error-display.md |
| Use Controller or useController with shadcn/ui or server actions | reference/controlled-inputs.md |
| Build dynamic arrays with useFieldArray and tune performance | reference/field-registration.md |
| Build multi-step forms with FormProvider and per-step validation | reference/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.