Skip to content

TrendingTechnology/react-hook-form

ย 
ย 
React forme Logo - React hook form valiation

React hook form validation without the hassle

Tweetย CircleCI Coverage Status npm downloads npm npm

  • Super easy to create forms and integrate
  • Build with React hook, performance and developer experience in mind
  • Follow html standard for validation
  • Tiny size without other dependency 2 kB (minified + gzipped)
  • Build a quick form with form builder

Install

$ npm install react-hook-form

Quickstart

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

function App() {
  const { register, handleSubmit, errors } = useForm()
  const onSubmit = (data) => { console.log(data) }
    
  return (
    <form onSubmit={handleSubmit(onSubmit)}>
      <input name="firstname" ref={register} />
      
      <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>
  )
}

About

๐Ÿ“‹ React hook for form validation without the hassle

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • TypeScript 97.2%
  • HTML 2.3%
  • JavaScript 0.5%