# Forms in React with React Hook Form

> Build performant, accessible forms with React Hook Form: registration, validation, errors, arrays and submission states. Free notes, key concepts, resources...

Canonical: https://www.internhack.in/roadmaps/tracks/frontend/react-forms
Last updated: 2026-11-28

Build performant, accessible forms with React Hook Form: registration, validation, errors, arrays and submission states.

Intermediate · about 4 hours · difficulty 3/5

Learn first: [HTML Forms and Native Validation](https://www.internhack.in/roadmaps/tracks/frontend/html-forms), [Hooks, Refs and State Patterns](https://www.internhack.in/roadmaps/tracks/frontend/react-hooks)

Forms are where users give you money and data, so they deserve care. Handling every field with `useState` gets verbose and re-renders on every keystroke. **React Hook Form** (RHF) keeps inputs mostly uncontrolled, re-renders only what needs it and gives you a tidy API for validation and errors.

### The basics

- `const { register, handleSubmit, formState: { errors, isSubmitting } } = useForm<FormValues>()`.
- `<input {...register("email", { required: "Email is required" })} />` wires up a field.
- `handleSubmit(onSubmit)` validates, then calls your function with typed values.
- `Controller` or `useController` integrates controlled components such as date pickers and custom selects.
- `useFieldArray` handles repeating groups (multiple addresses, line items).
- Pair it with a **schema resolver** (Zod) so validation rules live in one typed place.

### UX that matters

- Label every input with `<label>`; do not rely on placeholders.
- Validate on blur or submit, not on every keystroke from the first character.
- Show errors next to the field, connect them with `aria-describedby` and set `aria-invalid`.
- Move focus to the first invalid field on submit (RHF does this by default).
- Disable double submits, show progress, and keep the user's input after a server error.
- Map **server-side validation errors** back to fields with `setError`.

### Alternatives

TanStack Form (type-safe, framework-agnostic), Formik (older codebases) and native forms with React 19 Actions for simple cases.

### Good enough to move on

You can build a multi-field signup form with a dynamic field array, schema validation, accessible error messages and server error mapping.

## Key concepts

- **useForm and register**
- **handleSubmit and submission state**
- **Displaying errors accessibly**
- **Controller for custom inputs**
- **useFieldArray**
- **Mapping server errors with setError**
- **TanStack Form and Formik**

## Mini project

Build an invoice editor form: customer details, a dynamic list of line items with computed totals, a custom date picker via Controller and server-side error mapping from a mock API.

## Check yourself

Why does React Hook Form re-render less than a form built from one useState per field?

## Free resources

- [React Hook Form Get Started](https://react-hook-form.com/get-started) (React Hook Form)
- [TanStack Form](https://tanstack.com/form/latest) (TanStack)
- [Forms tutorial](https://www.w3.org/WAI/tutorials/forms/) (W3C WAI)

Previous: [GraphQL on the Frontend](https://www.internhack.in/roadmaps/tracks/frontend/graphql-clients) · Next: [Schema Validation with Zod](https://www.internhack.in/roadmaps/tracks/frontend/schema-validation)

## More in Routing, State and Data

- [Client-Side Routing](https://www.internhack.in/roadmaps/tracks/frontend/client-routing)
- [State Management Principles](https://www.internhack.in/roadmaps/tracks/frontend/state-management)
- [Client State Libraries: Zustand, Redux Toolkit and Jotai](https://www.internhack.in/roadmaps/tracks/frontend/state-libraries)
- [Server State with TanStack Query](https://www.internhack.in/roadmaps/tracks/frontend/server-state)
- [Working with REST APIs in Production](https://www.internhack.in/roadmaps/tracks/frontend/api-integration)
- [GraphQL on the Frontend](https://www.internhack.in/roadmaps/tracks/frontend/graphql-clients)
- [Forms in React with React Hook Form](https://www.internhack.in/roadmaps/tracks/frontend/react-forms)
- [Schema Validation with Zod](https://www.internhack.in/roadmaps/tracks/frontend/schema-validation)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Frontend Developer Roadmap](https://www.internhack.in/roadmaps/tracks/frontend)
