next-safe-actionplayground
Overview
  • Home
Core
  • Core Actions
  • Validation Errors
  • Middleware
Hooks
  • React Hooks
  • Optimistic Updates
Integrations
  • Form Integration
  • React Hook Form
  • TanStack Query
Framework
  • Navigation & Framework
  • GitHub

React Hooks

useAction hook with full status tracking, callbacks, forms, and state updates.

useAction Full Demo
All return properties: execute, executeAsync, result, status, reset, input, and all status flags.
Status:Idle
isIdle: trueisExecuting: falseisTransitioning: falseisPending: falsehasSucceeded: falsehasErrored: false
Result:
{}
initResult
Seed useAction with a preloaded result: result.data is populated while idle, and reset() restores the seeded value (even mid-execution, discarding the in-flight run).
Status:Idle
Result:
{
  "data": {
    "deletedUserId": "preloaded-user"
  }
}
Stateless Form
Form using useAction + execute to submit FormData directly.
Status:Idle
Result:
{}
State Update via onSuccess
Local state updated through the onSuccess callback when the action completes.

Local state: (none)

Status:Idle
Result:
{}