Skip to content
๐Ÿ“‹ React hooks for forms validation without the hassle.
TypeScript JavaScript HTML
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci โš™๏ธ Enhance CircleCI Config (#238) Aug 21, 2019
.github ๐Ÿ™๐Ÿป update bug report to include codesandbox link Oct 17, 2019
.vscode Default typescript version to what we are using in our project Aug 15, 2019
app ๐Ÿค˜feature on revalidate mode (#362) Oct 13, 2019
cypress ๐Ÿ‹๐Ÿปโ€โ™‚๏ธ fix isValid issue with validationFields and consistency with isโ€ฆ Oct 19, 2019
examples ๐Ÿ“– change array field to field array Sep 26, 2019
src ๐Ÿž fix dep issue (#394) Oct 20, 2019
website ๐Ÿ’ update logo (#350) Oct 6, 2019
.eslintrc.js ๐Ÿค˜ add Curly Eslint Rule (#391) Oct 18, 2019
.gitignore ๐Ÿ—‘ clean up ignore files Aug 26, 2019
.npmignore ๐Ÿ“ฆ improve form state isValid (#268) Aug 28, 2019
.npmrc Fix some utility functions (#168) Jul 30, 2019
.prettierrc ๐Ÿ’…๐Ÿป prettier the whole code base and update script Sep 3, 2019
CODE_OF_CONDUCT.md Create CODE_OF_CONDUCT.md Apr 3, 2019
CONTRIBUTING.md โค๏ธ Uplift the Contributing instructions (#364) Oct 11, 2019
LICENSE ๐Ÿ“… update License Sep 15, 2019
README.fr-FR.md ๐Ÿ‡ซ๐Ÿ‡ทFrench translation (#388) Oct 18, 2019
README.ja-JP.md ๐Ÿ‡ฏ๐Ÿ‡ต add Japanese doc (#372) Oct 15, 2019
README.md Update README.md Oct 18, 2019
README.zh-CN.md ๐Ÿ‡ฏ๐Ÿ‡ต add Japanese doc (#372) Oct 15, 2019
cypress.json disable video capture in cypress.json at build Aug 12, 2019
jest.config.js intial commit Mar 6, 2019
package.json ๐Ÿž fix dep issue (#394) Oct 20, 2019
rollup.config.js ๐Ÿฅ‚improve on getting value (#246) Aug 23, 2019
rollup.ie11.config.js โš™๏ธ Enhance CircleCI Config (#238) Aug 21, 2019
rollup.min.config.js ๐Ÿฅ‚improve on getting value (#246) Aug 23, 2019
setup.ts โš’ use mutationobserver-shim for unit test Sep 16, 2019
tsconfig.ie11.json push tsconfig for ie11 Aug 20, 2019
tsconfig.jest.json Remove errors from Typescript usage (#54) Jun 5, 2019
tsconfig.json ๐Ÿ’… update exclude folders Aug 31, 2019
yarn.lock ๐Ÿค˜ add Curly Eslint Rule (#391) Oct 18, 2019

README.md

Performant, flexible and extensible forms with easy to use for validation.

CircleCI npm downloads npm dep npm Coverage Status

Tweetย Join the community on Spectrum

๐Ÿ‡ฆ๐Ÿ‡บEnglish | ๐Ÿ‡จ๐Ÿ‡ณ็ฎ€ไฝ“ไธญๆ–‡ | ๐Ÿ‡ฏ๐Ÿ‡ตๆ—ฅๆœฌ่ฏญ | ๐Ÿ‡ซ๐Ÿ‡ท Franรงais

Features

  • Built with performance and DX in mind
  • Uncontrolled form validation
  • Tiny size without any dependency
  • Follows HTML standard for validation
  • Compatible with React Native
  • Support Yup schema-based validation
  • Support browser native validation
  • Build forms quickly with the form builder

Install

$ npm install react-hook-form

Links

Quickstart

import React from 'react';
import useForm from 'react-hook-form';

function App() {
  const { register, handleSubmit, errors } = useForm(); // initialise the hook
  const onSubmit = data => {
    console.log(data);
  };

  return (
    <form onSubmit={handleSubmit(onSubmit)}>
      <input name="firstname" ref={register} /> {/* register an input */}

      <input name="lastname" ref={register({ required: true })} />
      {errors.lastname && 'Last name is required.'}

      <input name="age" ref={register({ pattern: /\d+/ })} />
      {errors.age && 'Please enter number for age.'}

      <input type="submit" />
    </form>
  );
}

Contributors

Thanks goes to these wonderful people. [Become a contributor].

Backers

Thank goes to all our backers! [Become a backer].

You canโ€™t perform that action at this time.