useActionState
The React hook that wraps an Action and returns its latest result, a function to trigger it, and an isPending flag.
In more detail
useActionState(action, initialState) gives [state, formAction, isPending]; pass formAction to a form action prop. Each call receives the previous state and the submitted FormData, and whatever it returns becomes the new state, such as a success or error message.
Examples
const [state, formAction, isPending] = useActionState(updateProfile, { errors: {} });const [state, formAction, isPending] = useActionState(saveAction, null);Related terms
- useFormState — The earlier name of useActionState, from React DOM canary releases before React 19.
- isPending — A true or false value from hooks such as useActionState and useTransition that is true while an action is still running.
- Server Functions — Async functions marked with "use server" that run on the server but can be called from client components, for example as a form action.
- form action — The action prop of a form, or formAction on a button, which in React can be a Server Action that receives the submitted FormData.
- Action (React) — In React 19, an async function run inside a transition, typically to submit data, with pending state, errors and optimistic updates handled by React.
- FormData — A browser object holding the name and value of every field in a submitted form.
- pending state — The in-between state while asynchronous work, such as a transition or form submission, has started but not finished.
Taught in
- Server Actions: use server Directives & Mutations — Next.js 15 & Modern App Router Architecture
- Action State: useActionState & Optimistic Form UI — Next.js 15 & Modern App Router Architecture
- Server Action Security: Zod Validation & Auth Gates — Next.js 15 & Modern App Router Architecture
- Concurrent Mode: Interruptible Work And Lane Priority — React 19 & Modern Component Architecture
- useTransition: Non-Blocking State Updates for Fluid UI — React 19 & Modern Component Architecture
- useActionState: Async Action Handlers And Pending States — React 19 & Modern Component Architecture
- useOptimistic: Instantaneous UI Updates with Rollback — React 19 & Modern Component Architecture