Book a call Free rebuild
Home/Glossary/Astro/Astro Actions

Astro Actions

By Seahawk November 16, 2026

Astro glossaryAstro Actions are type-safe server functions, defined with defineAction() and validated with Zod, that pages and forms call without hand-written API endpoints.

Astro Actions are type-safe server functions you define once and call from the browser or from forms, without writing API endpoints by hand. They are defined with defineAction() in src/actions/index.ts, with an optional Zod schema that validates the input before your handler runs.

How they work

A component calls an action like a normal function and gets back either data or an error. Actions accept JSON by default, or HTML form data with accept: 'form', so a plain form can submit to one. Astro handles the request, parsing, and validation.

Actions are public URLs under /_actions/, so they need the same permission checks as any API route. Calling one from an HTML form needs the page to be rendered on demand.

Source: Astro docs: Actions.

Em Workers

EmDash and Astro sites at revolutionary pricing.

Lightning-fast, secure websites delivered on EmDash and Astro. For the AI-curious bunch.