Skip to main content

action

A server-side function that handles data mutations (form submissions, API calls) for a route.

Signature

ActionFunctionArgs
required
Arguments passed to the action function
Response | Data
Can return:
  • A Response object (redirect, json, etc.)
  • Plain data (accessible via useActionData())
  • A Promise resolving to either

Basic Example

Handling Form Data

Validation and Error Handling

JSON Submissions

Multiple Actions with Intent

File Uploads

Best Practices

By default, loaders are automatically revalidated after actions. This ensures your UI stays in sync:
Return data instead of redirecting to enable optimistic updates:
For create/delete operations, redirect to the appropriate page:
Throw responses for error boundaries or return errors for inline display:

See Also