React Hook Form
Performant form state library using React Hooks with minimal rerenders.
3. Used by agents' projects
Dependency in 569 public GitHub projects set up for AI coding agents that we scanned (9.1%).
4. Agent access
Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.
From the package registry and GitHub, checked daily. Tap a verdict to see its source.How we checkedReport an error
What React Hook Form does
React Hook Form is built around uncontrolled inputs: <code>register</code> captures the input's ref instead of wiring <code>value</code>/<code>onChange</code> through React state, and the maintainers present this as the way to cut re-renders while users type.
React Hook Form popularity
Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated
How React Hook Form is used
- React Hook Form is a dependency in 569 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (11.7% of the 4,867 JavaScript/TypeScript ones), #2 of 63 in forms, validation and schemas.
- Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 2,187; those are left out of every share on this page.
- The most used alternative in our scan is TanStack Form (20 projects).
- Projects that use it most often also use clsx (89.3%), Lucide React (88.4%), Tailwind Merge (88.4%).
- It is more common in projects set up for Roo Code (16.2%) than for OpenCode (5.2%).
By coding agent
Often used with
React Hook Form in practice
Strengths
Most inputs stay uncontrolled. When a component has to be controlled, the FAQ says <code>Controller</code> or <code>useController</code> limits re-renders to that one field.
The site says you can subscribe to updates for a single input or for form state without re-rendering the entire form.
The maintainers describe it as "a tiny library without any dependencies." The README lists "Small size and no dependencies" among its features.
The README says it supports Yup, Zod, AJV, Superstruct, Joi "and others", linking the separate resolvers repository.
Watch out for
The FAQ answers "No, not out of the box" for class components. Its suggestion is to build a wrapper around the hook and use that in the class component.
The FAQ ties the "first keystroke not working" problem to passing <code>value</code>. Use <code>defaultValue</code> per field or <code>defaultValues</code> on the form instead.
The library needs the input's ref. If you also need a ref for focus or scrolling, the FAQ splits <code>ref</code> out of <code>register()</code> and passes the element to both in one callback.
Quickstart: register inputs and show errors
import { useForm } from 'react-hook-form';
function App() {
const {
register,
handleSubmit,
formState: { errors },
} = useForm();
return (
<form onSubmit={handleSubmit((data) => console.log(data))}>
<input {...register('firstName')} />
<input {...register('lastName', { required: true })} />
{errors.lastName && <p>Last name is required.</p>}
<input {...register('age', { pattern: /\d+/ })} />
{errors.age && <p>Please enter a number for age.</p>}
<input type="submit" />
</form>
);
}More about React Hook Form
Funding
- GitHub Sponsors: https://github.com/bluebill1049
- GitHub Sponsors: https://github.com/jorisre
- GitHub Sponsors: https://github.com/kotarella1110
- Open Collective: https://opencollective.com/react-hook-form
- Own page: https://youtube.com/@bluebill1049
- 7 GitHub sponsors
Agent Skills for it
- react-hook-form: React Hook Form performance optimization for client-side form validation using useForm, useWatch, useController, useFieldArray, the subscrib
Packages around it
- zod: Schema validation
- clsx: Conditional class names
- lucide-react: Icons
- tailwind-merge: Tailwind class merging
- @hookform: Schema resolvers
- class-variance-authority: Variant class names
More in Forms, validation and schemas
Alternatives
React Hook Form This page
Type-safe form state management for React with validation and error handling.
Popular React form state management library with validation and submission handling.
Get started
Install it.
npm install react-hook-formRules for your agent
## React Hook Form
- Wire native inputs with `{...register('name', rules)}`. Do not add `value`/`onChange` state: `register` captures the ref.
- Never pass `value` to a registered input. Initialize with `defaultValues` on `useForm`, or `defaultValue` per field.
- For async initial data, make `defaultValues` an async function, or pass fetched data as `values` with `resetOptions: { keepDirtyValues: true }`.
- Wrap components that must stay controlled in `Controller` or `useController`, so only that field re-renders.
- If you need your own ref, destructure `const { ref, ...rest } = register('x')` and pass the element to both RHF's `ref` and your own ref in one callback.
- To clear a form including errors, use RHF's `reset()`. `HTMLFormElement.reset()` only clears input/select/checkbox values.
- For accessible errors, set `aria-invalid` from `errors.field` and render the message in an element with `role="alert"`.