Reference

Basic Action

Start with a small validated Astro Action and connect it to a form with translated feedback.

Included by npx @samline/astro add actions. Active use requires a compatible server adapter. On pure static hosting, request inactive scaffolding with --scaffold and configure the backend before enabling the registration.

A request-time FormData example with bounded input, explicit locale validation, same-origin checks and dictionary messages. It does not send email or write data.

import { actions } from 'astro:actions'

const submit = async (form: HTMLFormElement) => {
  const { data, error } = await actions.basic(new FormData(form))
  // Render the translated message through the owning section's status UI.
  return { data, error }
}

Supply named name and locale controls. Native HTML forms also work with Astro’s Action URL/result APIs. Keep UI inside sections and use Fields only if installed. The installer registers this Action on supported server profiles. An explicitly requested static scaffold keeps inactive index.ts.example registration; add a server adapter and merge its registration into an existing index.ts, or rename/uncomment it when no active entry exists, before calling the Action. Never expose private operations without independent authorization and resource checks.