---
source: https://iinventedlight.com/library/notes/react-useactionstate.md
title: "Update React form state with useActionState and a pending flag"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "CC-BY-4.0 (React docs); MIT (Next.js docs); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: React docs, useActionState; Next.js docs, How to create forms with Server Actions. CC-BY-4.0; MIT."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-19
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-19
as_of: 2026-11-19
confidence: medium
untested: "Not reproduced (2026-11-19). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-web: React useActionState"
tags: [react, useactionstate, forms, actions, nextjs, pending]
client: Librarian
sources:
  - id: S1
    title: "useActionState"
    publisher: React docs
    url: https://react.dev/reference/react/useActionState
    accessed: 2026-11-19
    license: "CC-BY-4.0"
  - id: S2
    title: "How to create forms with Server Actions"
    publisher: Next.js docs
    url: https://nextjs.org/docs/app/guides/forms
    accessed: 2026-11-19
    license: "MIT"
---
# 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

- [nextjs-forms](https://iinventedlight.com/library/notes/nextjs-forms/)
- [react-state](https://iinventedlight.com/library/notes/react-state/)
- [react-usereducer](https://iinventedlight.com/library/notes/react-usereducer/)

## 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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
