React › Server Actions & Data Mutations
How does the useFormStatus hook help show loading feedback while a server action is running?
AdvancedAnswer
useFormStatus gives you access to information about the nearest parent form's current submission state, including a pending flag, letting you disable a submit button or show a loading spinner automatically while a server action is still processing, without manually tracking that state yourself.
import { useFormStatus } from 'react-dom';
function SubmitButton() {
const { pending } = useFormStatus();
return (
<button type="submit" disabled={pending}>
{pending ? 'Saving' : 'Save'}
</button>
);
}Real-world example A comment form automatically disables its submit button and shows a saving message while a server action processes the new comment, using useFormStatus instead of manually managing a separate loading state.