Install with Astro
Add the Diorama integration to Astro and start the app once in the layout.
Astro builds with Vite, so the integration adds the same plugin as the Vite setup. Effects go in src/effects/.
Install the packages
npm install @dioramajs/diorama threepnpm add @dioramajs/diorama threeyarn add @dioramajs/diorama threebun add @dioramajs/diorama threeAdd the integration
import diorama from '@dioramajs/diorama/astro'
export default { integrations: [diorama()] }Start the app in the layout
Call start() in a <script> of the layout every page uses. Astro bundles the script and runs it once, so the app lives across pages.
---import { ClientRouter } from 'astro:transitions'---
<html lang="en"> <head> <meta charset="utf-8" /> <title>Diorama</title> <ClientRouter /> </head> <body> <slot /> <script> import { start } from '@dioramajs/diorama' start() </script> </body></html>Put an effect on an image
---import Layout from '../layouts/Layout.astro'---
<Layout> <img src="/cover.jpg" width="800" height="450" data-dio="ripple" /></Layout>With <ClientRouter /> in the layout, elements with the same data-dio-key fly between pages without more code. Your first page transition shows how.