Astro
Tegaki provides a native Astro component that renders full HTML at build time and hydrates on the client. No JavaScript framework required — text is visible even before hydration.
Installation
Section titled “Installation”Basic example
Section titled “Basic example”Hello World
Font registration
Section titled “Font registration”When using the same font across multiple components on a page, you can register the bundle once and reference it by name. This avoids duplicating the font data in the HTML output.
Register the bundle
Section titled “Register the bundle”Use the bundle prop on a dedicated instance — it serializes the font data into a <script type="application/json"> tag and registers it on the client:
Preload the font
Section titled “Preload the font”Add loadFont to inject an @font-face rule so the browser starts downloading the font file immediately:
Effects
Section titled “Effects”Fancy effects
How it works
Section titled “How it works”- Build time — The Astro component calls
TegakiEngine.renderElements()to produce the full HTML (canvas fallback text, overlay, sentinel). Text is visible in the initial HTML even without JavaScript. - Client hydration — A module script finds all
[data-tegaki-options]elements, creates aTegakiEnginewithadopt: true(reusing existing DOM), and starts the animation. - Dynamic elements — A
MutationObserverwatches for elements added after initial load (e.g., from View Transitions or client-side routing) and hydrates them automatically.
The Astro component accepts all TegakiEngineOptions plus:
| Prop | Type | Description |
|---|---|---|
bundle | boolean | Register the font bundle for client-side lookup by name |
loadFont | boolean | Inject @font-face CSS for early font loading |
class | string | CSS class on the container |