# React Hook Form — card for AI agents

Performant form state library using React Hooks with minimal rerenders.

Category: Forms, validation and schemas · npm package `react-hook-form` · latest version 7.91.0 (checked 2026-11-01)
Install: `npm install react-hook-form`
License: MIT (permissive)

In your own product (generator, app, hosted service): **yes**. Permissive license: ship it inside your own product, closed or open source, and keep its license and copyright notice.

## Rules for AI agents (paste into AGENTS.md or CLAUDE.md)

## 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"`.

## Agent Skills for it
- react-hook-form from midudev/autoskills: `npx skills add midudev/autoskills --skill react-hook-form`

## What it is
- React Hook Form is a set of React hooks for form state and validation. The repository describes it as working on "Web + React Native". It was created in March 2019 and is MIT licensed. You call `useForm()` and get back `register`, `handleSubmit` and `formState`. You then spread `register('name', rules)` onto each input.
- The central design choice is stated in the FAQ: "the register function captures a ref directly instead of value / onChange." Validation rules such as `required`, `pattern` and custom `validate` functions are passed next to each field. Fields that must stay controlled go through `Controller` or `useController`.
- The site pitches it as something you can drop into an existing app on its own: "Since form state is inherently local, it can be easily adopted without other dependencies."

## Caveats
- Class components need a wrapper: 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.
- Setting `value` breaks typing: The FAQ ties the "first keystroke not working" problem to passing `value`. Use `defaultValue` per field or `defaultValues` on the form instead.
- Sharing the ref takes extra wiring: The library needs the input's ref. If you also need a ref for focus or scrolling, the FAQ splits `ref` out of `register()` and passes the element to both in one callback.
- No ref means manual updates: You can register a field without a ref. The docs warn that the library then cannot attach event listeners, so you update value and error yourself.
- Field-array reindexing fixed only in v7.90.0: The v7.90.0 release notes fix `useFieldArray` unregistering fields while a parent array reindexes. Nested field arrays on older versions may hit this.

## Numbers (AgentGid data)
- Gid Score: 86.5 (#23 of all tools, 2 of 63 in its category)
- Used in 569 public projects set up for AI coding agents (9.1%)
- Downloads last week: 68,283,187 (as of 2026-11-24), +19.1% over 4 weeks
- GitHub stars: 44,926 (as of 2026-11-24)
- Last push: 2026-11-22

## Often used with
clsx 89.3%, Lucide React 88.4%, Tailwind Merge 88.4%, React Hook Form Resolvers 87.0%, Class Variance Authority 83.8%, Zod 90.3%

## Checked alternatives (same job)
- TanStack Form: https://agentgid.com/tools/tanstack-react-form/agent.md
- Formik: https://agentgid.com/tools/formik/agent.md

## Links
- AgentGid page: https://agentgid.com/tools/react-hook-form/
- Homepage: https://react-hook-form.com
- Repository: https://github.com/react-hook-form/react-hook-form
- Source: https://github.com/react-hook-form/react-hook-form#readme
- Source: https://github.com/react-hook-form/react-hook-form
- Source: https://github.com/react-hook-form/react-hook-form/releases
- Source: https://react-hook-form.com
- Source: https://react-hook-form.com/faqs

---
AgentGid's catalog is curated: every entry was checked against the maker's official pages (registry, repository, license and pricing pages) on the date shown; a license value shows the quote it stands on wherever AgentGid has one. Usage numbers come from AgentGid's own scan of public repositories set up for AI coding agents. Claims by makers are reported, not tested by AgentGid.
