This commit is contained in:
2026-03-18 20:54:43 +01:00
parent b3c8b77f12
commit 9fe656b34c
8058 changed files with 912898 additions and 23 deletions
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019-present Beier(Bill) Luo
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+126
View File
@@ -0,0 +1,126 @@
<div align="center">
<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>
</div>
<div align="center">
[![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)
</div>
<p align="center">
<a href="https://react-hook-form.com/get-started">Get started</a> |
<a href="https://react-hook-form.com/docs">API</a> |
<a href="https://react-hook-form.com/form-builder">Form Builder</a> |
<a href="https://react-hook-form.com/faqs">FAQs</a> |
<a href="https://github.com/react-hook-form/react-hook-form/tree/master/examples">Examples</a>
</p>
### Features
- Built with performance, UX and DX in mind
- Embraces native HTML form [validation](https://react-hook-form.com/get-started#Applyvalidation)
- Out of the box integration with [UI libraries](https://codesandbox.io/s/react-hook-form-v7-controller-5h1q5)
- [Small size](https://bundlephobia.com/result?p=react-hook-form@latest) and no [dependencies](./package.json)
- Support [Yup](https://github.com/jquense/yup), [Zod](https://github.com/colinhacks/zod), [AJV](https://github.com/ajv-validator/ajv), [Superstruct](https://github.com/ianstormtaylor/superstruct), [Joi](https://github.com/hapijs/joi) and [others](https://github.com/react-hook-form/resolvers)
### Install
npm install react-hook-form
### Quickstart
```jsx
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
Were incredibly grateful to these kind and generous sponsors for their support!
<a target="_blank" href="https://thanks.dev/"><img width="120" src="https://avatars.githubusercontent.com/u/72539280?s=200&v=4" /></a>
<a target="_blank" href="https://www.follower24.de/"><img width="120" src="https://images.opencollective.com/follower24/00297f8/avatar/256.png?height=256" /></a>
<a target="_blank" href='https://workleap.com/'><img width="120" src="https://images.opencollective.com/workleap/db82f38/logo/256.png?height=256" /></a>
<a target="_blank" href="https://kinsta.com/"><img width="120" src="https://images.opencollective.com/kinsta/55912d7/logo/256.png?height=256" /></a>
<a target="_blank" href='https://www.sent.dm'><img width="120" src="https://avatars.githubusercontent.com/u/153308555?s=200&v=4" /></a>
<a target="_blank" href='https://niche.com'><img width="120" src="https://avatars.githubusercontent.com/u/8988784?s=200&v=4" /></a>
<a target="_blank" href='https://toss.im'><img width="120" src="https://images.opencollective.com/toss/3ed69b3/logo/256.png" /></a>
<a target="_blank" href='https://principal.com/about-us'><img width="120" src="https://images.opencollective.com/principal/431e690/logo/256.png?height=256" /></a>
<a target="_blank" href="https://hygraph.com"><img width="120" src="https://avatars.githubusercontent.com/u/31031438" /></a>
<a target="_blank" href="https://kanamekey.com"><img width="120" src="https://images.opencollective.com/kaname/d15fd98/logo/256.png" /></a>
### Past Sponsors
Thank you to our previous sponsors for your generous support!
<a target="_blank" href="https://www.beekai.com/"><img width="24" src="https://www.beekai.com/marketing/logo/logo.svg" /></a>
<a target="_blank" href='https://route4me.com/'><img width="24" src="https://images.opencollective.com/route4me/71fb6fa/avatar/256.png?height=256" /></a>
<a target="_blank" href='https://www.sgkb.ch/'><img width="24" src="https://images.opencollective.com/st-galler-kantonalbank-ag/bfdd17f/logo/256.png?height=256" /></a>
<a target="_blank" href='https://www.sanity.io/'><img width="24" height="24" src="https://images.opencollective.com/sanity_io/558f87f/logo/256.png?height=256" /></a>
<a target="_blank" href='https://twicsy.com/'><img width="24" height="24" src="https://images.opencollective.com/buy-instagram-followers-twicsy/b4c5d7f/logo/256.png?height=256" /></a>
<a href="https://www.leniolabs.com/" target="_blank"><img src="https://www.leniolabs.com/images/leniolabs-isologo-example.jpg" width="24" height="24" /></a>
<a target="_blank" href="https://underbelly.is"><img width="24" src="https://images.opencollective.com/underbelly/989a4a6/logo/256.png" /></a>
<a target="_blank" href="https://feathery.io"><img width="24" src="https://images.opencollective.com/feathery1/c29b0a1/logo/256.png" /></a>
<a target="_blank" href="https://getform.io"><img width="24" src="https://images.opencollective.com/getformio2/3c978c8/avatar/256.png" /></a>
<a href="https://marmelab.com/" target="_blank"><img src="https://images.opencollective.com/marmelab/d7fd82f/logo/256.png" width="24" height="24" /></a>
<a target="_blank" href="https://formcarry.com/"><img width="24" src="https://images.opencollective.com/formcarry/a40a4ea/logo/256.png" /></a>
<a target="_blank" href="https://fabform.io"><img width="24" src="https://images.opencollective.com/fabform/2834037/logo/256.png" /></a>
<a target="_blank" href="https://www.thinkmill.com.au/"><img width="24" src="https://images.opencollective.com/thinkmill/28910ec/logo/256.png" /></a>
<a target="_blank" href="https://kwork.studio/"><img width="24" src="https://images.opencollective.com/knowledge-work/f91b72d/logo/256.png" /></a>
<a target="_blank" href="https://fiberplane.com/"><img width="24" src="https://avatars.githubusercontent.com/u/61152955?s=200&v=4" /></a>
<a target="_blank" href="https://www.jetbrains.com/"><img width="24" src="https://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.png" /></a>
<a target="_blank" href="https://www.mirakl.com/"><img width="24" src="https://images.opencollective.com/mirakl/0b191f0/logo/256.png" /></a>
<a target="_blank" href='https://wantedlyinc.com'><img width="24" src="https://images.opencollective.com/wantedly/d94e44e/logo/256.png" /></a>
<a target="_blank" href="https://www.casinoreviews.net/"><img width="24" src="https://images.opencollective.com/casinoreviews/f0877d1/logo/256.png" /></a>
### Backers
Thanks go to all our backers! [[Become a backer](https://opencollective.com/react-hook-form#backer)].
<a href="https://opencollective.com/react-hook-form#backers">
<img src="https://opencollective.com/react-hook-form/backers.svg?width=820" />
</a>
### Contributors
Thanks go to these wonderful people! [[Become a contributor](CONTRIBUTING.md)].
<a href="https://github.com/react-hook-form/react-hook-form/graphs/contributors">
<img src="https://opencollective.com/react-hook-form/contributors.svg?width=820" />
</a>
<br />
<br />
<a href="https://ui.dev/bytes/?r=bill">
<img src="https://raw.githubusercontent.com/react-hook-form/react-hook-form/master/docs/ads-1.jpeg" />
</a>
<br />
<br />
<p align="center">Documentation website supported and backed by <a href="https://vercel.com"><b>Vercel</b></a></p>
+141
View File
@@ -0,0 +1,141 @@
{
"name": "react-hook-form",
"description": "Performant, flexible and extensible forms library for React Hooks",
"version": "7.71.2",
"main": "dist/index.cjs.js",
"module": "dist/index.esm.mjs",
"umd:main": "dist/index.umd.js",
"unpkg": "dist/index.umd.js",
"jsdelivr": "dist/index.umd.js",
"jsnext:main": "dist/index.esm.mjs",
"source": "src/index.ts",
"types": "dist/index.d.ts",
"sideEffects": false,
"files": [
"dist"
],
"exports": {
"./package.json": "./package.json",
".": {
"types": "./dist/index.d.ts",
"react-server": "./dist/react-server.esm.mjs",
"import": "./dist/index.esm.mjs",
"require": "./dist/index.cjs.js"
}
},
"scripts": {
"clean": "rimraf dist",
"prepare": "husky",
"prebuild": "pnpm clean",
"build": "pnpm build:modern",
"build:watch": "pnpm build:modern -w",
"postbuild": "node ./scripts/rollup/assert-esm-exports.mjs && node ./scripts/rollup/assert-cjs-exports.cjs",
"build:modern": "rollup --bundleConfigAsCjs -c ./scripts/rollup/rollup.config.js",
"build:esm": "rollup --bundleConfigAsCjs -c ./scripts/rollup/rollup.esm.config.js",
"prettier:fix": "prettier --config .prettierrc --write .",
"lint": "eslint . --cache",
"lint:fix": "pnpm lint --fix",
"type": "tsc --noEmit",
"jest-preview": "jest-preview",
"test": "jest --config ./scripts/jest/jest.config.js",
"test:coverage": "pnpm test --coverage",
"test:watch": "pnpm test --onlyChanged --watch",
"test:web": "TEST_ENV=web pnpm test",
"test:type": "tsd src/__typetest__",
"e2e": "cypress run",
"e2e:watch": "cypress open",
"api-extractor": "api-extractor run --local",
"api-extractor:build": "pnpm build:esm && pnpm api-extractor",
"api-extractor:ci": "node scripts/apiExtractor.js",
"postversion": "git push && git push origin v$npm_package_version",
"prepublishOnly": "pnpm install && pnpm lint:fix && pnpm type && pnpm test && pnpm build",
"bundlewatch": "pnpm build:modern && bundlewatch",
"start": "pnpm build:esm && pnpm --dir ./app install && pnpm --dir ./app run dev",
"csb:install": "npm i -g pnpm@8 && pnpm i"
},
"keywords": [
"react",
"hooks",
"form",
"forms",
"form-validation",
"validation",
"typescript",
"react-hooks"
],
"repository": {
"type": "git",
"url": "https://github.com/react-hook-form/react-hook-form"
},
"homepage": "https://react-hook-form.com",
"author": "Beier(Bill) Luo <bluebill1049@hotmail.com>",
"license": "MIT",
"devDependencies": {
"@eslint/compat": "^1.4.1",
"@microsoft/api-extractor": "^7.55.2",
"@rollup/plugin-commonjs": "^28.0.9",
"@rollup/plugin-node-resolve": "^16.0.3",
"@rollup/plugin-terser": "^0.4.4",
"@swc/core": "^1.15.3",
"@swc/jest": "^0.2.39",
"@testing-library/jest-dom": "^6.9.1",
"@testing-library/react": "^16.3.0",
"@types/jest": "^30.0.0",
"@types/node": "^25.0.3",
"@types/react": "^19.2.7",
"@types/react-dom": "^19.2.3",
"bundlewatch": "^0.4.1",
"cypress": "^15.7.1",
"eslint": "^9.39.2",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-cypress": "^5.2.0",
"eslint-plugin-prettier": "^5.5.4",
"eslint-plugin-react": "^7.37.5",
"eslint-plugin-react-hooks": "^7.0.1",
"eslint-plugin-simple-import-sort": "^12.1.1",
"husky": "^9.1.7",
"jest": "^30.2.0",
"jest-environment-jsdom": "^30.2.0",
"jest-fixed-jsdom": "^0.0.10",
"jest-preview": "^0.3.2",
"lint-staged": "^16.2.7",
"prettier": "^3.7.4",
"react": "^19.2.3",
"react-dom": "^19.2.3",
"rimraf": "^6.1.2",
"rollup": "^4.53.3",
"rollup-plugin-typescript2": "^0.36.0",
"tsd": "^0.33.0",
"typescript": "^5.9.3",
"typescript-eslint": "^8.49.0",
"whatwg-fetch": "^3.6.20",
"zod": "^3.25.76"
},
"bundlewatch": {
"files": [
{
"path": "./dist/index.cjs.js",
"maxSize": "11.25 kB"
}
]
},
"peerDependencies": {
"react": "^16.8.0 || ^17 || ^18 || ^19"
},
"lint-staged": {
"*.{js,ts,tsx}": [
"pnpm lint:fix",
"pnpm prettier:fix"
],
"*.{md,json,yml}": [
"prettier --write"
]
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/react-hook-form"
},
"engines": {
"node": ">=18.0.0"
}
}