What are Astro's server actions (Astro Actions)?

Answer

Astro Actions (introduced in Astro 4.15) provide type-safe server functions callable from the client, similar to Remix actions but for any Astro component including framework components. Define in src/actions/index.ts: import { defineAction, z } from "astro:actions"; export const server = { subscribe: defineAction({ input: z.object({ email: z.string().email() }), handler: async ({ email }) => { await db.addSubscriber(email); return { success: true }; } }) };. Call from any client-side code: import { actions } from "astro:actions"; const result = await actions.subscribe({ email: "alice@example.com" });. In React island: const { error, data } = await actions.subscribe(formData);. Actions provide: End-to-end type safety (input validated with Zod), Form-compatible (use action={actions.subscribe} directly on <form>), Progressive enhancement (works as HTML form without JS). Astro Actions bring Remix-style server mutations to Astro's framework-agnostic model.