Skip to main content

Actions and async Transitions

React 19 gives a first-class name and set of patterns to a workflow that modern applications perform constantly.

Action lifecycleUser intent can start async work without turning the resulting UI update into urgent rendering work.
1User intent
2Start Action / Transition
3Async work runs
4Urgent UI stays responsive
5Pending feedback stays local
6Confirmed result renders

React calls functions executed inside a Transition Actions.

An Action is not a replacement for event handlers, Effects, or API functions. It coordinates updates that may include asynchronous work while React treats the resulting UI update as non-urgent.

Start with the problem​

Imagine changing the quantity of an item:

async function updateQuantity(nextQuantity) {
const response = await fetch('/api/cart', {
method: 'POST',
body: JSON.stringify({quantity: nextQuantity}),
});

return response.json();
}

The network request is ordinary JavaScript. The React question is how the UI should behave while it is happening and when its result updates rendered state.

useTransition​

import {useState, useTransition} from 'react';

function QuantityEditor() {
const [quantity, setQuantity] = useState(1);
const [isPending, startTransition] = useTransition();

function saveQuantity(nextQuantity) {
startTransition(async () => {
const saved = await updateQuantity(nextQuantity);

startTransition(() => {
setQuantity(saved.quantity);
});
});
}

return (
<button disabled={isPending} onClick={() => saveQuantity(quantity + 1)}>
{isPending ? 'Saving…' : `Quantity: ${quantity}`}
</button>
);
}
What startTransition changes
startTransition(action)
Action executes now
It is not delayed like setTimeout.
Transition rendering
Non-urgent rendering may yield to more urgent interaction.

startTransition changes update priority; it does not postpone the callback.

Action naming is a convention​

A callback intended to run as Transition work can use an Action suffix:

function SubmitButton({submitAction}) {
const [isPending, startTransition] = useTransition();

return (
<button
disabled={isPending}
onClick={() => {
startTransition(async () => {
await submitAction();
});
}}
>
Submit
</button>
);
}
Event callback vs Action-shaped callback
EventonClick
Represents the browser/user event boundary.
ActionsubmitAction
Represents an operation intended to participate in Transition coordination.

The name is a convention, not special JavaScript syntax.

Actions can contain side effects​

A reducer passed to useReducer must remain pure. An Action may perform side effects:

startTransition(async () => {
const result = await saveProfile(formValues);
// state update follows
});

That difference matters when comparing useReducer with useActionState.

Actions are not Effects​

Do not move user-triggered work into an Effect merely because it is asynchronous.

Bad:

useEffect(() => {
if (shouldSave) {
saveProfile();
}
}, [shouldSave]);

Better:

function handleSave() {
startTransition(async () => {
await saveProfile();
});
}
Where should this work start?
Directly caused by user intent?Event handler / Action
Must stay synchronized with an external system because rendering changed?Effect

Pending state​

useTransition returns:

const [isPending, startTransition] = useTransition();

Use isPending for local feedback:

<button disabled={isPending}>
{isPending ? 'Updating…' : 'Update'}
</button>

Pending UI should usually preserve context instead of replacing the whole screen with a global spinner.

State updates after await​

A current React limitation matters when an Action awaits asynchronous work.

startTransition(async () => {
const result = await saveSomething();

setValue(result); // not automatically Transition work today
});

Wrap state updates after the await in another startTransition:

startTransition(async () => {
const result = await saveSomething();

startTransition(() => {
setValue(result);
});
});
Async Transition boundary
startTransition
Async boundary
React currently loses automatic Transition marking for later setters.
startTransition(() => setState(...))

Treat this as a current implementation limitation, not a timeless conceptual rule.

Urgent vs non-urgent updates​

Update priorityTransitions are for work that can yield to more urgent interaction.
Urgent
Controlled typing Β· direct pointer interaction Β· immediate button/menu feedback.
Transition candidate
Navigation Β· expensive tab content Β· mutation result rendering Β· background recalculation.

Do not put controlled input state itself in a Transition:

function SearchBox() {
const [query, setQuery] = useState('');

function handleChange(event) {
setQuery(event.target.value); // immediate
}

return <input value={query} onChange={handleChange} />;
}

Use synchronous state for the input. useDeferredValue or a separate Transition-backed result can lag behind without making typing lag.

Action props​

Reusable components can own pending presentation while callers provide domain behavior:

function SaveButton({action}) {
const [isPending, startTransition] = useTransition();

return (
<button
disabled={isPending}
onClick={() => {
startTransition(async () => {
await action();
});
}}
>
{isPending ? 'Saving…' : 'Save'}
</button>
);
}

<SaveButton action={() => saveProfile(profile)} />

Request ordering still matters​

Raw async Transitions do not automatically solve race conditions.

Out-of-order async completion
Request A
Starts first Β· finishes last.
Request B
Starts second Β· finishes first.
Ordering strategy required
Use a higher-level ordered Action model or explicit request identity/cancellation when correctness depends on recency.

useActionState and form Actions help with common ordered mutation flows. Custom async Transition code may still need explicit request-ordering logic.

Common mistakes​

  • Using Actions for every async function. A normal async event handler is still valid.
  • Treating Transition work as delayed work. The callback runs immediately.
  • Ignoring failures. Expected validation/domain errors need a user-facing state model; unexpected failures need an error strategy.
  • Showing pending UI too broadly. Keep feedback close to the operation.
  • Using Transition state to control text inputs.

Production decision guide​

Do I need an Action / Transition?
Async work does not update React UI?Ordinary async function may be enough
UI update is immediate and cheap?Normal state update may be enough
Update should be non-blocking and expose pending UI?Transition / Action pattern
Mutation result depends on previous Action result?Consider useActionState

Interview questions​

Junior: What does startTransition change about a state update?

Mid-level: Why should controlled input state usually not be updated inside a Transition?

Senior: What race conditions can remain when building custom async Actions, and when would useActionState be a better abstraction?

References​

Next​

Continue with useActionState to manage Action result state, pending state, and ordered updates.