Update React form state with useActionState and a pending flag
Answer: useActionState is a Hook that lets you update state with side effects using Actions. It returns [state, dispatchAction, isPending]. In Next.js, a Server Action on a form can be that Action.
The hook
Call useActionState(reducerAction, initialState, permalink?) at the top level of your component or your own Hooks, not inside loops or conditions. The reducerAction receives the previous state and returns a new state. Unlike useReducer, it can be async and perform side effects. React queues multiple dispatchAction calls sequentially. dispatchAction must be called from an Action, for example via startTransition or an Action prop. If it throws an error, React cancels all queued actions and shows the nearest Error Boundary.
isPending is a flag for pending Actions. The permalink URL is used rather than the current page's URL when the JavaScript bundle has not loaded. When using Server Functions, initialState needs to be serializable.
Forms in Next.js
React Server Actions are Server Functions that execute on the server. Calling them works from Server and Client Components. When used in a form, the function automatically receives the form data. Forms can be validated on the client or server. A pending boolean can show a loading indicator or disable the submit button while the action is being executed.
Gotcha
An async function with useActionState called outside of a transition is an error, and isPending will not update correctly. Do not call dispatchAction during render.
See also
Claims
- id: C1 claim: useActionState lets you update state with Actions. source: S1 evidence: "useActionState is a React Hook that lets you update state with side effects using Actions"
- id: C2 claim: The hook must be called at the top level of a component. source: S1 evidence: "you can only call it at the top level of your component"
- id: C3 claim: A Server Action on a form is invoked when the form is submitted. source: S2 evidence: "element to allow Server Actions to be invoked with the"
Sources
- [S1] useActionState. React docs. https://react.dev/reference/react/useActionState . License: CC-BY-4.0. Accessed 2026-11-19.
- [S2] How to create forms with Server Actions. Next.js docs. https://nextjs.org/docs/app/guides/forms . License: MIT. Accessed 2026-11-19.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: React docs, useActionState; Next.js docs, How to create forms with Server Actions. CC-BY-4.0; MIT. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: React docs, useActionState; Next.js docs, How to create forms with Server Actions. CC-BY-4.0; MIT.
Cite this
iinventedlight. 2026. "Update React form state with useActionState and a pending flag." iinventedlight Library, iil:note:a3t8h1ry, version of 2026-11-19. https://iinventedlight.com/library/notes/react-useactionstate/. License: CC-BY-4.0.
@misc{iil_note_a3t8h1ry,
author = {{iinventedlight}},
title = {{Update React form state with useActionState and a pending flag}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-19},
url = {https://iinventedlight.com/library/notes/react-useactionstate/},
note = {Permanent ID iil:note:a3t8h1ry. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/react-useactionstate.md.