Skip to content


A component to provide React Context

This component will host context object and allow consuming component to subscribe to context and use useForm props and methods.


This following table applied to FormProvider, useFormContext accepts no argument.

...propsObjectFormProvider requires all useForm methods.
  • Avoid using nested FormProvider


import React from "react"
import { useForm, FormProvider, useFormContext } from "react-hook-form"
export default function App() {
const methods = useForm()
const onSubmit = (data) => console.log(data)
return (
<FormProvider {...methods}>
// pass all methods into the context
<form onSubmit={methods.handleSubmit(onSubmit)}>
<NestedInput />
<input type="submit" />
function NestedInput() {
const { register } = useFormContext() // retrieve all hook methods
return <input {...register("test")} />

Thank you for your support

If you find React Hook Form to be useful in your project, please consider to star and support it.