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

Core Actions

Basic action patterns: direct calls, async schemas, auth context, and output validation.

Direct Call
Basic action with inputSchema, invoked directly with useState.
Result:
—
Async Schema
inputSchema with an async factory function — schema is resolved at runtime.
Result:
—
Auth Context
authAction with chained .use() middleware — ctx.userId and ctx.sessionId available in the action.
Result:
—
No Arguments
Action without an input schema — just call it.
Result:
—
Empty Response
Action that returns void — useful for side-effect-only operations.
Result:
—
Output Schema
Using .outputSchema() to validate the return data from the action.
Result:
—