React Hook Form Logo - React hook custom hook for form validation
React Hook Form video - React custom hook for form validation
[![npm downloads](https://img.shields.io/npm/dm/react-hook-form.svg?style=for-the-badge)](https://www.npmjs.com/package/react-hook-form) [![npm](https://img.shields.io/npm/dt/react-hook-form.svg?style=for-the-badge)](https://www.npmjs.com/package/react-hook-form) [![npm](https://img.shields.io/npm/l/react-hook-form?style=for-the-badge)](https://github.com/react-hook-form/react-hook-form/blob/master/LICENSE) [![Discord](https://img.shields.io/discord/754891658327359538.svg?style=for-the-badge&label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.gg/yYv7GZ8)

开始 | API | 示例 | Demo | 表单生成器 | 常见问题

### Features - 以性能和开发体验为基础构建 - 支持浏览器原生校验 - [UI库](https://codesandbox.io/s/react-hook-form-v7-controller-5h1q5)开箱即用 - [小巧](https://bundlephobia.com/result?p=react-hook-form@latest)无[依赖](./package.json) - 遵循 HTML 标准进行[校验](https://react-hook-form.com/get-started#Applyvalidation) - 支持[Yup](https://github.com/jquense/yup), [Zod](https://github.com/vriad/zod), [Superstruct](https://github.com/ianstormtaylor/superstruct), [Joi](https://github.com/hapijs/joi), [Vest](https://github.com/ealush/vest), [class-validator](https://github.com/typestack/class-validator), [io-ts](https://github.com/gcanti/io-ts), [nope](https://github.com/bvego/nope-validator)或自定义 ### 安装 npm install react-hook-form ### 快速开始 ```jsx import React from 'react'; import { useForm } from 'react-hook-form'; function App() { const { register, handleSubmit, formState: { errors }, } = useForm(); const onSubmit = (data) => console.log(data); return (
{/* register an input */} {errors.lastName &&

Last name is required.

} {errors.age &&

Please enter number for age.

}
); } ``` ### 赞助者 感谢所有可爱及热情的(公司/个人)赞助者

@sayav @lemcii @washingtonsoares @lixunn @SamSamskies @peaonunes @wilhelmeek @iwarner @joejknowles @chris-gunawardena @Tymek @Luchanso @vcarel @gragland @tjshipe @krnlde @msutkowski @mlukaszczyk

### 支持者 感谢所有支持者! [[成为支持者](https://opencollective.com/react-hook-form#backer)]. ### 贡献者 感谢这些出色的人! [[成为贡献者](../CONTRIBUTING.md)]. ### 帮助者 感谢您帮助及回答社区中的问题 ## 组织机构 感谢这些精彩的组织! [[捐助](https://opencollective.com/react-hook-form/contribute)]