<a href="https://react-hook-form.com" title="React Hook Form - Simple React forms validation">
<img src="https://raw.githubusercontent.com/react-hook-form/react-hook-form/master/docs/logo.png" alt="React Hook Form Logo - React hook custom hook for form validation" />
</a>
Get started | API | Form Builder | FAQs | Examples
npm install react-hook-form
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 &&
Last name is required.
}
<input {...register('age', { pattern: /\d+/ })} />
{errors.age &&
Please enter number for age.
}
<input type="submit" />
</form>
);
}
We’re incredibly grateful to these kind and generous sponsors for their support!
| Follower24 | BuyFans |
|---|---|
![]() |
| Thanks.dev | Workleap | Kinsta | Sent | Niche |
|---|---|---|---|---|
![]() |
![]() |
|||
| Toss | Principal | Hygraph | ||
![]() |
![]() |
Thank you to our previous sponsors for your generous support!
Thanks go to all our backers! [Become a backer].
Thanks go to these wonderful people! [Become a contributor].
Documentation website supported and backed by Vercel
$ claude mcp add react-hook-form \
-- python -m otcore.mcp_server <graph>