Documentation Index
Fetch the complete documentation index at: https://kubo-47e69177.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
defineAction
defineAction validates input/output at runtime and keeps static typing across server and client usage.
Signature
packages/core/src/defineAction.ts
Options
| Option | Type | Required | Notes |
|---|---|---|---|
input | ZodType<TInput> | Yes | Runtime input validation |
output | ZodType<TOutput> | No | Runtime output validation |
name | string | No | Used by logger |
tags | readonly string[] | No | Passed to revalidateTags |
beforeAction | (args) => void | Promise<void> | No | Runs before handler |
afterAction | (args) => TOutput | void | Promise<TOutput | void> | No | Runs after handler, may override result |
handler | ({ input, ctx }) => Promise<TOutput> | Yes | Main implementation |
Example
app/actions.ts
Failure modes
- Missing context factory throws a runtime error from
resolveActionContext. - Invalid input/output throws Zod validation errors.
- Empty tags are ignored by server revalidation.