* feat: baseline experimental actions * feat(test): remove experimental config * feat: remove getActionProps() * feat: make actions file non-break * feat: detect actions usage * chore: changeset * feat: improve actions usage check * refactor: remove define action symbol now that we check server exp * fix: remove old import * chore: move actionsIntegration to top import * fix: warn only when actions are used * fix: srcDir check * refactor: split out action plugins to simplify integration * feat: new integration and plugins * chore: update error hints * fix(test): pass default src dir * feat: add ActionNotFoundError * fix: handle json parse errors in deserializer * chore: unused import * 500 -> 404 * New `astro:schema` module (#11810) * feat: expose zod from astro:schema * chore: changeset * chore: update release strategy in changeset * fix: move deprecated notice to type def * fix: update config doc reference * chore: remove z from astro:actions * edit: changeset with minor release note remove * wip: increase button click timeouts * Revert "wip: increase button click timeouts" This reverts commit a870bc2dc4bdfd77b8b4fc54b62d8bde01d20c14. * chore: remove content collections disclaimer * fix: undo biome change * agh tabs * agh newlines * fix: bad docs merge * wip: add back timeout extension * fix(test): astro schema import * refactor: move static output error to config done * refactor: usesActions -> isActionsFilePresent * fix: check whether startup and current value disagree * chore: unused import * edit: sell actions a little more * changeset nit --------- Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
1.4 KiB
astro |
---|
minor |
The Astro Actions API introduced behind a flag in v4.8.0 is no longer experimental and is available for general use.
Astro Actions allow you to define and call backend functions with type-safety, performing data fetching, JSON parsing, and input validation for you.
Actions can be called from client-side components and HTML forms. This gives you to flexibility to build apps using any technology: React, Svelte, HTMX, or just plain Astro components. This example calls a newsletter action and renders the result using an Astro component:
---
// src/pages/newsletter.astro
import { actions } from 'astro:actions';
const result = Astro.getActionResult(actions.newsletter);
---
{result && !result.error && <p>Thanks for signing up!</p>}
<form method="POST" action={actions.newsletter}>
<input type="email" name="email" />
<button>Sign up</button>
</form>
If you were previously using this feature, please remove the experimental flag from your Astro config:
import { defineConfig } from 'astro'
export default defineConfig({
- experimental: {
- actions: true,
- }
})
If you have been waiting for stabilization before using Actions, you can now do so.
For more information and usage examples, see our brand new Actions guide.