Astro Integration
FluxFX is SSR-safe to import in Astro and supports both zero-hydration .astro templates and @astrojs/react islands.
1. Zero-Hydration .astro Pages
src/pages/index.astro • astro
<section data-fx="prism-3d" data-fx-shape="torus" style="min-height: 65vh;">
<h1>Astro + FluxFX</h1>
</section>
<script>
import { FluxFX } from '@votax572002/fluxfx';
FluxFX.init();
</script> Vite Tree-Shaking Note (
sideEffects: false)
Because package.json declares "sideEffects": false, always import { FluxFX } and call FluxFX.init() inside Astro <script> tags rather than using a bare side-effect import.
2. Astro View Transitions (ClientRouter)
When using Astro View Transitions, DOMContentLoaded only runs on initial load. Hook into Astro's lifecycle events to tear down old contexts and scan newly swapped DOM nodes:
src/layouts/BaseLayout.astro • astro
<script>
import { FluxFX } from '@votax572002/fluxfx';
document.addEventListener('astro:page-load', () => FluxFX.init());
document.addEventListener('astro:before-swap', () => FluxFX.destroyAll());
</script> 3. Astro React Islands (@astrojs/react)
Island Example • astro
---
import { Prism3D } from '@votax572002/fluxfx/react';
---
<Prism3D client:visible shape="orb" quality="high" style={{ minHeight: '50vh' }}>
<h2>Hydrated when visible</h2>
</Prism3D>