Skip to content
๐Ÿ“‹ React hooks for form 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 FUNDING.yml to include opencollective Aug 21, 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 ๐Ÿค˜feature on revalidate mode (#362) Oct 13, 2019
examples ๐Ÿ“– change array field to field array Sep 26, 2019
src ๐Ÿž close #367 patch async validate function result type Oct 14, 2019
website ๐Ÿ’ update logo (#350) Oct 6, 2019
.eslintrc.js ๐Ÿ•ต๐Ÿผโ€โ™‚๏ธ code name clean up and method overload for reset (#247) Aug 23, 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.md ๐ŸŽ– update circle ci badge Oct 9, 2019
README.zh-CN.md ๐ŸŒน update chinese doc (#292) Sep 4, 2019
cypress.json disable video capture in cypress.json at build Aug 12, 2019
jest.config.js intial commit Mar 6, 2019
package.json 3.24.0 Oct 13, 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 ๐Ÿ† close #352 add GestureResponderEvent for event type (#353) Oct 7, 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 | ๐Ÿ‡จ๐Ÿ‡ณ็ฎ€ไฝ“ไธญๆ–‡

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.