Skip to main content

useActionData

Returns the action data from the most recent form submission, or undefined if there hasn’t been one.
This hook only works in Data and Framework modes.

Signature

Parameters

None.

Returns

SerializeFrom<T> | undefined
The data returned from the most recent route action, or undefined if no action has been called.

Usage

Basic usage

With TypeScript (Framework mode)

Form validation

Redirect on success

Multiple forms

Use the name attribute to distinguish forms:

Return Response objects

Common Patterns

Preserve form data on error

Return the submitted data along with errors:

Clear action data

Action data persists until the next navigation. To clear it:

Loading state

Combine with useNavigation for loading UI:

Type Safety

With generics