useFormStatus: Reading Parent Form State
What You'll Learn
You'll learn how useFormStatus lets child components read a parent form's pending state without passing props down through every level.
The Prop Drilling Problem
When building forms with loading indicators, you'd typically pass the pending state from useActionState down to buttons, spinners, or disabled inputs. In deeply nested components, this becomes tedious:
<Form>
<FormSection pending={pending}>
<SubmitButton pending={pending} />
</FormSection>
</Form>
Every layer needs the prop, even if it just passes it along.
How useFormStatus Solves This
useFormStatus is a hook that reads the submission state of the nearest parent <form> element. Any component inside a form can call it directly:
import { useFormStatus } from 'react-dom';
function SubmitButton() {
const { pending } = useFormStatus();
return (
<button type="submit" disabled={pending}>
{pending ? 'Submitting...' : 'Submit'}
</button>
);
}
function MyForm() {
return (
<form action={myServerAction}>
<input name="email" />
<SubmitButton /> {/* No props needed! */}
</form>
);
}
The SubmitButton component automatically knows if the form is submitting—no prop drilling required.
The Context Analogy
Think of useFormStatus like React Context, but specifically for form state. The <form> element acts as an invisible provider, and useFormStatus is the consumer. Only children inside the form can read its status.
Key Details
- Must be called in a child component, not the component rendering the
<form> - Returns
{ pending, data, method, action }—most commonly you'll usepending - Works with both client and server actions
Key Takeaway: useFormStatus eliminates prop drilling by letting any child component inside a form directly access its pending state, making loading indicators and disabled states simpler to implement.