npm install react-hook-form

Performant, flexible and extensible forms library for React Hooks

About react-hook-form

React Hook Form is a leading library for managing forms in React applications, known for its performance, flexibility, and extensibility. This library simplifies form management by leveraging React hooks, allowing developers to create complex forms with minimal code. React Hook Form reduces the amount of re-rendering that occurs with user inputs, improving performance significantly compared to other form handling libraries. It supports native form validation, which eliminates the need for additional dependencies and streamlines the development process. By emphasizing an uncontrolled component architecture, React Hook Form ensures that form values are managed efficiently without unnecessary re-renders, making it an ideal choice for large-scale applications that prioritize speed and resource efficiency.

To start using React Hook Form in your project, you can easily integrate it by running the command `npm install react-hook-form`. This simple installation adds a robust set of tools to your development environment, enabling you to handle complex form validation with ease. The library's API provides features like `useForm` for hooking into form state and actions, and `Controller` to wrap custom components with validation logic. React Hook Form is compatible with both class components and functional components, making it a versatile choice for developers working with different React paradigms. By choosing React Hook Form, developers can significantly reduce development time and improve form performance, thanks to its intuitive API and focus on minimizing re-renders.

React Hook Form stands out for its comprehensive documentation and active community support, making it accessible to both beginners and experienced developers. The library is continuously updated to support the latest React features and best practices, ensuring that your applications remain up-to-date with modern development standards. With its emphasis on performance and ease of use, React Hook Form is an indispensable tool for developers looking to streamline their React application workflows and enhance user form interactions. Whether you are building simple contact forms or complex multi-step forms, React Hook Form provides the tools and flexibility needed to create highly responsive and performant form solutions.

More from react-hook-form

react-hook-form npm packages

Find the best node modules for your project.

Search npm

react-hook-form

Performant, flexible and extensible forms library for React...

Read more
,

@hookform/resolvers

React Hook Form validation resolvers: Yup, Joi, Superstruct, Zod, Vest, Class Validator, io-ts,...

Read more
,

react-hook-form-paste

simple declarative bindings for react-hook-form and Twilio React Paste components...

Read more

Dependencies

Core dependencies of this npm package and its dev dependencies.

@microsoft/api-extractor, @rollup/plugin-commonjs, @rollup/plugin-node-resolve, @rollup/plugin-terser, @swc/core, @swc/jest, @testing-library/jest-dom, @testing-library/react, @testing-library/react-hooks, @types/jest, @types/react, @types/react-dom, @types/testing-library__jest-dom, @typescript-eslint/eslint-plugin, @typescript-eslint/parser, bundlewatch, cypress, eslint, eslint-config-prettier, eslint-plugin-cypress, eslint-plugin-prettier, eslint-plugin-react, eslint-plugin-react-hooks, eslint-plugin-simple-import-sort, husky, jest, jest-environment-jsdom, jest-preview, lint-staged, msw, prettier, react, react-dom, react-test-renderer, rimraf, rollup, rollup-plugin-peer-deps-external, rollup-plugin-sourcemaps, rollup-plugin-typescript2, tsd, typescript, whatwg-fetch

Documentation

A README file for the react-hook-form code repository. View Code

React Hook Form Logo - React hook custom hook for form validation

npm downloads npm npm Discord

Get started | API | Form Builder | FAQs | Examples

Features

Install

npm install react-hook-form

Quickstart

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 number for age.</p>}
      <input type="submit" />
    </form>
  );
}

Sponsors

Thanks go to these kind and lovely sponsors!

Past sponsors

Backers

Thanks go to all our backers! [Become a backer].

Contributors

Thanks go to these wonderful people! [Become a contributor].