Performant, flexible and extensible forms with easy to use validation.
Migrate your React Hook Form codebase from older version to new without the hassle by using our codemod scrips
npx @hookform/codemod <transform> <path> [...options]
transform- name of transform, see available transforms below.path- files or directory to transform- use the
--dryoption for a dry-run and use--printto print the output for comparison
This will start an interactive wizard, and then run the specified transform.
Update the register API inside a component which use useForm of React Hook Form. This transform is not applied if the component doesn't use useForm.
npx @hookform/codemod v7/update-register Examples
- <input ref={register} name="example" /> + <input {...register('example')} /> - <input ref={register()} name="example" /> + <input {...register('example')} /> - <input ref={register()} name="example" /> + <input {...register('example')} /> - <input ref={register({ required: true })} name="example" /> + <input {...register('example', { required: true })} /> - <TextInput ref={register({ required: true })} name="example" /> + <TextInput {...register('example', { required: true })} />With a custom register name
function MyForm() { const { register: customRegister } = useForm(); return ( <form> - <input ref={customRegister} name="example" /> + <input {...customRegister('example')} /> </form> ); }Thanks goes to all our backers! [Become a backer].
Thanks goes to these wonderful organizations! [Contribute].
Thanks goes to these wonderful people! [Become a contributor].