Astro can own the document, routing and content while Aster owns a booking control, filter or editor inside it. Start with one island. The examples below target the Aster 1.2.3 adapter. The downloadable fixture pairs it with Astro 6.4.8.
An interactive island component
This is a built Astro page. Its heading and button arrive as HTML. When the island becomes visible, Astro loads Aster so the button can update in place.
import './example.css';
export default function* Panel(props, ctx) {
let seats = 1;
for (props of ctx) yield <section class="booking">
<h1>{props.caption ?? 'Workshop seats'}</h1>
{props.children}
<div class="seat-count"><output>{seats}</output><span>seats on your booking</span></div><button onClick={() => seats++}>Reserve a seat · {seats}</button>
</section>;
}
*{box-sizing:border-box}
body{margin:0;padding:1rem;background:light-dark(#ecf2ed,#1e2924);color:light-dark(#203b30,#eff8f1);font:1rem/1.5 system-ui}
.booking{max-width:32rem;margin:auto;background:light-dark(#fffdfa,#29392f);border:1px solid light-dark(#bdcec4,#506658);border-radius:.65rem;padding:1.1rem 1.4rem}
h1{font:600 1.45rem Georgia,serif;margin:0}.booking p{margin:.45rem 0}
.seat-count{border-top:1px dashed currentColor;display:flex;align-items:baseline;gap:.65rem;padding:.45rem 0}.seat-count output{font:600 2.25rem Georgia,serif}
button{background:light-dark(#235640,#b6d9bf);color:light-dark(white,#192c20);border:0;border-radius:.4rem;padding:.55rem .8rem;font:inherit;cursor:pointer}button:focus-visible{outline:3px solid currentColor;outline-offset:2px}
---
import Panel from '../components/Panel.aster.jsx';
---
<html lang="en"><head><meta charset="utf-8"><meta name="robots" content="noindex"><title>Workshop booking</title></head><body>
<main id="example" data-ready="astro-panel"><Panel client:visible><span slot="caption">Workshop seats</span><p>Choose how many places to reserve.</p></Panel></main>
</body></html>
import { defineConfig } from "astro/config";
import aster from "@fierst/aster/astro";
export default defineConfig({ integrations: [aster({ include: ["**/*.aster.jsx"] })] });
Choose an activation policy
| What the visitor needs | Astro directive | Browser behavior |
|---|---|---|
| Read-only content | Omit the directive | The component renders to HTML. Event handlers do not run. |
| An immediately usable control | client:load | Astro loads the renderer and activates the component on page load. |
| A lower-priority control | client:idle | Activation waits for browser idle time. |
| A widget below the fold | client:visible | Visibility triggers loading and activation. |
| A strictly browser-only widget | client:only="aster" | The component mounts in the browser without its server-rendered content. |
A client directive goes on the directly imported component in the .astro template. In a mixed JSX project, give each renderer a distinct include pattern. The examples use .aster.tsx; the downloadable fixture uses .aster.jsx with the same extension in its include pattern.
Install the adapter
npm install @fierst/aster@1.2.3Install @fierst/aster in the Astro app and register its integration in astro.config.mjs. The integration installs the Aster Vite transform and registers the server and browser renderers.
import { defineConfig } from 'astro/config';
import aster from '@fierst/aster/astro';
export default defineConfig({
integrations: [aster({ include: ['**/*.aster.tsx'] })],
});Here the suffix identifies files that Aster owns in a mixed-framework project. Configure other JSX integrations to exclude those files. With the default configuration, Aster processes all JSX and TSX. The integration accepts include, exclude and runtimeImport. Set jsxImportSource to @fierst/aster for Aster TSX types, or use a file-level JSX import source pragma in a mixed project.
Create src/components/Panel.aster.tsx.
/** @jsxImportSource @fierst/aster */
import type { Ctx, View } from '@fierst/aster';
type Props = { caption?: View; children?: View };
export function* Panel(props: Props, ctx: Ctx<Props>) {
let count = 0;
for (props of ctx) {
yield (
<section>
<h2>{props.caption}</h2>
{props.children}
<button onClick={() => count++}>Clicks: {count}</button>
</section>
);
}
}Render it in src/pages/index.astro.
---
import { Panel } from '../components/Panel.aster';
---
<Panel client:visible>
<span slot="caption">Cart</span>
<p>Items in this order</p>
</Panel>The default slot becomes props.children and each named slot becomes the prop of the same name. Astro supplies rendered slot HTML. Render those props as views. With client:visible, the server sends the section and Astro activates it when visible. Use client:load for immediate activation, client:idle for idle time, or client:media="(min-width: 50em)" for a media query. Omit the directive for static HTML. Use client:only="aster" to mount entirely in the browser.
Astro owns the activation schedule. Its island contains Aster's claim markers. The client renderer attaches to the existing children, preserves compatible input state and disposes on astro:unmount during client navigation. The standalone installRevival bootstrap belongs to Aster-rendered documents.
Adapter entry points
The default integration is also exported as asterAstro. Its types are AsterAstroOptions, AstroIntegration, AstroRendererConfig and AstroSetupContext. The default export of @fierst/aster/astro/server exposes check and renderToStaticMarkup, also available as named exports. The former selects Aster components. The latter receives Component, props, slots and optional AstroComponentMetadata and asynchronously returns AstroServerRenderResult with html and optional attrs. AstroServerRenderer describes that contract.
The default export of @fierst/aster/astro/client accepts the island element and returns an async function accepting Component, props, slots and AstroClientOptions (client directive). It claims existing HTML or mounts fresh content for an empty or client-only island. Astro invokes these adapter functions for you.
Verify the island
Run npm ci and npx astro build in the downloadable fixture, then npx astro preview. Inspect the page source for the workshop heading, the named caption slot and the initial button. With JavaScript enabled, scroll the panel into view and click Reserve a seat. The count increases while the parent Astro page stays in place.