astro-actions

Implements type-safe Astro server actions with Zod validation and progressive form enhancement.

1|Updated Jul 29, 2026
One-click install
npx skills add https://github.com/fusengine/kimi-code --skill astro-actions-fusengine
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: astro-actions
Source: https://github.com/fusengine/kimi-code/tree/main/plugins/astro-expert/skills/astro-actions
Command: npx skills add https://github.com/fusengine/kimi-code --skill astro-actions-fusengine

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Building form submissions and server mutations in Astro often means writing ad-hoc API endpoints with manual validation and inconsistent error handling. This Skill provides a standardized pattern for type-safe server functions using Astro Actions, so validation, errors, and client calls stay consistent. ## Core Features & Use Cases - Type-Safe Server Actions: Define actions with defineAction() and Zod-validated input schemas in src/actions/index.ts, called from the client via the astro:actions import. - Standardized Error Handling: Throw ActionError with HTTP-aligned codes (UNAUTHORIZED, FORBIDDEN, NOT_FOUND, BAD_REQUEST, CONFLICT, TOO_MANY_REQUESTS, INTERNAL_SERVER_ERROR) and catch them client-side with isActionError. - Progressive Enhancement: Use accept: 'form' so HTML forms submit directly to actions and work without JavaScript, with getActionResult for server-rendered success/error state. - Use Case: Build a contact form where the server action validates name, email, and message with Zod, the plain HTML form works without JS, and a small script enhances it to submit via AJAX without a page reload. ## Quick Start Create an Astro server action with Zod input validation for my contact form and wire it to a progressively enhanced HTML form.

Frequently Asked Questions about astro-actions

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a server action in Astro?▼

Define actions in src/actions/index.ts using defineAction from astro:actions with a Zod input schema and a handler function, exported through a server object. Call them from the client by importing actions from astro:actions for fully typed requests.

How to handle HTML form submissions with Astro Actions?▼

Set accept: 'form' on the action so it parses FormData directly, then point the HTML form's action attribute at the action. Zod validators handle type coercion for numbers, checkboxes, files, and multi-value fields automatically.

Astro Actions vs API endpoints: which should I use?▼

Use Actions for form submissions, server mutations, and type-safe client-server calls. Use API endpoints for file downloads, binary responses, webhook receivers, and complex REST APIs where Actions' request/response model does not fit.

How do I return typed errors from an Astro action?▼

Throw an ActionError with a standardized code such as UNAUTHORIZED, NOT_FOUND, or TOO_MANY_REQUESTS and a message. On the client, check result.error and use isActionError to branch on specific codes for user-facing messages.

Do Astro Actions work without JavaScript enabled?▼

Yes, when using accept: 'form' with a native HTML form, submission works without JavaScript. Use getActionResult in the page frontmatter to render success or error state after the redirect, then layer a script for AJAX enhancement.