Action is React 19's name for a function run inside a Transition, usually async. Because it's a Transition, React knows when it starts and ends: isPending stays true until it finishes and its state updates commit, a thrown error reaches the nearest error boundary (with useTransition or a form action; the standalone startTransition reports it as uncaught), and useOptimistic and useActionState can build on it.
<form action={fn}> turns a form submission into an Action. On submit, React:
- cancels the browser's navigation (no
preventDefaultin your code); - builds
new FormData(form, submitter)and callsfn(formData)insidestartTransition; - marks the form pending, which children read with
useFormStatus(); - after
fncompletes without throwing, callsform.reset(), so uncontrolled fields return to theirdefaultValue. Controlled fields keep their state.
A <button formAction={fn}> (or <input type="submit">) overrides the form's action for that button. A string action or formAction is ordinary HTML: the browser submits and navigates.
onSubmit is just an event handler. You call e.preventDefault(), read new FormData(e.currentTarget) or your state, track loading and error state yourself, and nothing resets. It runs before React's action handling, and calling preventDefault() in it cancels the action. It's still right when you need the event (synchronous validation that blocks submission) or a form library that owns submission.
The action prop also accepts a Server Function, which lets a server-rendered form submit before JavaScript loads; onSubmit can't.
useFormStatus() returns { pending, data, method, action } for the parent <form>. Call it in the component that renders the form and pending is always false; it has to be in a child, typically the submit button.
To reset manually, call requestFormReset(form) from react-dom inside a Transition.