next-safe-action
playground
Toggle Sidebar
Overview
Home
Core
Core Actions
Validation Errors
Middleware
Hooks
React Hooks
Optimistic Updates
Forms
Form Integration
React Hook Form
Framework
Navigation & Framework
GitHub
Toggle theme
Toggle Sidebar
Core Actions
Basic action patterns: direct calls, async schemas, auth context, and output validation.
Direct Call
Basic action with inputSchema, invoked directly with useState.
View Code
Username
Password
Execute
Result:
—
Async Schema
inputSchema with an async factory function — schema is resolved at runtime.
View Code
Username
Password
Execute
Result:
—
Auth Context
authAction with chained .use() middleware — ctx.userId and ctx.sessionId available in the action.
View Code
Full Name
Age
Execute
Result:
—
No Arguments
Action without an input schema — just call it.
View Code
Execute
Result:
—
Empty Response
Action that returns void — useful for side-effect-only operations.
View Code
User ID (UUID)
Execute
Result:
—
Output Schema
Using .outputSchema() to validate the return data from the action.
View Code
Name
Execute
Result:
—