From fuse-astro
Expert Astro Server Actions — defineAction, astro:actions, Zod validation, ActionError, HTML form actions, accept form, progressive enhancement, redirect patterns. Use when handling form submissions, mutations, or any server-side logic with type safety.
How this skill is triggered — by the user, by Claude, or both
Slash command
/fuse-astro:astro-actionsThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Type-safe server functions with automatic validation, standardized errors, and progressive enhancement.
Type-safe server functions with automatic validation, standardized errors, and progressive enhancement.
Before ANY implementation, use TeamCreate to spawn 3 agents:
src/actions/After implementation, run fuse-ai-pilot:sniper for validation.
| Feature | Benefit |
|---|---|
defineAction() | Type-safe server function definition |
| Zod validation | Automatic JSON and FormData parsing |
ActionError | Standardized error codes and messages |
accept: 'form' | Direct HTML form submission support |
| Progressive enhancement | Works without JavaScript enabled |
astro:actions | Client import for type-safe calls |
All actions live in src/actions/index.ts and export a server object:
// src/actions/index.ts
import { defineAction } from 'astro:actions';
import { z } from 'astro/zod';
export const server = {
myAction: defineAction({ /* ... */ })
}
| Mode | Description |
|---|---|
accept: 'json' (default) | Parses JSON request body |
accept: 'form' | Parses HTML FormData directly |
Standard HTTP-aligned codes: UNAUTHORIZED, FORBIDDEN, NOT_FOUND, BAD_REQUEST, INTERNAL_SERVER_ERROR, CONFLICT, TOO_MANY_REQUESTS.
| Need | Reference |
|---|---|
| Concepts & architecture | overview.md |
| defineAction patterns | defining-actions.md |
| ActionError handling | error-handling.md |
| HTML form integration | forms.md |
| Progressive enhancement | progressive-enhancement.md |
| Contact form template | templates/contact-form.md |
| JSON action template | templates/json-action.md |
input schema — Never skip Zod validationActionError for known errors — Standardized codes for client handlingaccept: 'form' for HTML forms — Native form submission supportctx.cookies for auth — Throw UNAUTHORIZED when not logged innpx claudepluginhub fusengine/agents --plugin fuse-astroBuilds REST API routes, webhooks, and form handlers inside Astro projects using .ts endpoint files and middleware API.
Guides Next.js Server Actions for form handling, data mutations with useFormState/useFormStatus, and revalidation via revalidatePath/Tag in App Router.
Astro DB — defineDb, defineTable, column types, CRUD with db.select/insert/update/delete, db/config.ts, db/seed.ts, Turso for production, type-safety, integration with Astro Actions. Use for any database operation in an Astro project.