Skip to content

Astro integration ​

Use @hedystia/astro to render Hedystia View components in Astro and activate reactive islands with Astro's client directives.

sh
npm install @hedystia/astro @hedystia/view

Register the integration in astro.config.mjs:

js
import { defineConfig } from "astro/config";
import view from "@hedystia/astro";

export default defineConfig({ integrations: [view()] });

Configure JSX for your View components:

json
{
  "compilerOptions": {
    "jsx": "react-jsx",
    "jsxImportSource": "@hedystia/view"
  }
}

Then import a View component into an Astro page:

astro
---
import Counter from "../components/Counter.tsx";
---

<Counter client:load />

Empty components and slots ​

Components that intentionally return null or an empty string are accepted by the renderer. Default slots and named slots are passed to the component. Named slot names convert hyphenated or underscored words to camel case, so hero_slot becomes the heroSlot prop. Slot names are escaped when inserted into HTML attributes; slot content is Astro-rendered HTML.

Client activation and cleanup ​

The first activation hydrates the server-rendered island in place. Compatible native DOM nodes retain their identity, focus, selection and live form edits. Events and reactive updates bind directly to those nodes without a virtual DOM. Existing Astro slot nodes and their nested islands keep their own DOM and owners.

client:only mounts fresh content because it has no component SSR to adopt. Repeated activation with the same component and serialized props preserves the existing owner and reactive state. Changed props replace that owner and mount the updated component. The integration disposes the component on astro:unmount.

Use Astro's client directives to control activation. Keep the initial server and client structures consistent: mismatched elements are repaired locally and replaced subtrees lose their local DOM state. Use View ref callbacks for imperative access to adopted nodes. See static builds and islands for the hydration model.

See View rendering and lifecycle cleanup.