on:* handlers instead of hx-* attributes.
Hypermedia defaults to
false. Enable it only when you need fragment swaps. HTMX remains fully
supported alongside Aero hypermedia.Prerequisites
Fragment actions need something to call. For API routes that return HTML, enable Nitro first — see Server. Forbusy bindings and automatic binding processing after swaps, enable both flags:
aero.config.ts
Basic fragment load
Page:server/api/panel.get.ts):
GET, POST, PUT, PATCH, and DELETE are available in on:* handlers when hypermedia is enabled — no import needed.
Call them from <script is:state> only after an explicit import:
<script is:build> — that is a compile error.
Action methods
Each function takes a URL and an optional options object (see action options and swap modes).
Load a panel (
GET):
POST — use on:submit.prevent):
<form>, field name values are serialized into the request body automatically.
Update or delete (PUT, PATCH, DELETE):
<form> triggers, PUT, PATCH, and DELETE are sent as POST with a hidden _method field so servers that expect method override (common in Rails-style APIs) work without JavaScript.
Progressive enhancement by method
Action options
Second argument to every action function:GET('/api/url', { … }).
Swap target and mode
target
CSS selector for the element that receives the response. Defaults to the element that triggered the action (the button, link, or form).
swap
How response HTML is inserted relative to the target. Names match HTMX swap modes and map to insertAdjacentHTML / innerHTML behavior.
Replace panel contents (
innerHTML — default):
beforeend):
outerHTML):
remove):
Loading state
Tie a boolean signal to request lifecycle withbusy or the state action option (requires both reactivity and hypermedia):
Progressive enhancement
For staticGET on <a> and POST on <form>, the compiler emits native href / action when the URL is a string literal. JavaScript enhances those elements when hypermedia is active.
Next steps
Hypermedia recipes
Inline panels, partial form posts, loading UX, lifecycle hooks.
Using hypermedia with reactivity
Reactive swapped fragments,
busy, and shared page state.Reactive bindings
busy, events, and form bindings used with actions.Server routes
Nitro handlers that return HTML fragments.