Aperveil for React
Next.js, Vite and any React 18.2+ app: a typed component per shader, set with props.
Install
React 18.2 or newer: Next.js (App and Pages Router), Vite and any other React setup. Download a shader's Export Kit from its editor first; the packages it needs are inside.
Download and extract an Export Kit first, then run this command from its root. The required Aperveil packages are included; public npm and CLI releases are coming soon.
Add a shader
Copy the component from the kit into your project, import it and give it a size. The canvas fills the box you give it. In the editor, Install writes these lines for any shader, with the values you tuned.
Keep headings, links and anything important in HTML above or beside the shader: the canvas is a visual layer, not your document.
Props
Every control in the editor is a typed prop; your editor reads their types and descriptions. Leave one out and the shader keeps its own value; change one and the running shader updates without restarting. Each shader's page lists all of its props with ranges and defaults.
Every component also takes className, style, paused, fallback, onReady, onError:
| Prop | Type | What it does |
|---|---|---|
| className | string | Size and place the surface. The canvas fills this box, so give it a width and a height. |
| style | CSSProperties | Inline styles for the surface box. |
| paused | boolean | Holds the current frame. Use it for a pause control or for sections scrolled out of view. |
| fallback | ReactNode | Shown instead of the canvas without WebGPU. Also shown if rendering fails. A poster image or a CSS gradient works well. |
| onReady | () => void | The first frame has been drawn. |
| onError | (error: unknown) => void | Rendering failed; the fallback is shown. |
Video and images
Thermal Vision, Riso Print, Stipple Relief and Reeded Waveform play a video or an image through the shader. Give it the URL as src: an MP4, WebM, MOV, JPG, PNG or WebP.
| Prop | Type | What it does |
|---|---|---|
| src | string | The video or image it plays. A URL to an MP4, WebM, MOV, JPG, PNG or WebP, on your own site or on a server that allows it (CORS). Left out, it plays its own clip; an empty string shows its own scene. |
| mediaFocus | readonly [number, number] | Where the subject sits. Its place in the picture, from the top left, kept in view when the picture is cropped to fill. |
| mediaKind | "video" | "image" | Video or image. Only needed when the URL does not end in a file extension. |
Without one, Thermal Vision and Riso Print play their own sample clip from the Aperveil CDN (use your own in production), and Stipple Relief and Reeded Waveform show their own scene. The clip plays muted, looped and inline, and holds still while the shader is paused, scrolled out of view or under reduced motion. A clip on your own site always plays; one on another server must allow it (CORS). A short clip of 5 to 15 seconds with one clear subject loops best.
Glass Reel shows a gallery: up to 8 pictures and clips (2 of them clips) on its film. Pass them as gallery, an array of { src, type, alt }. Dew Glass sits on a picture: give its URL as backgroundImage. Without them, Glass Reel shows its own sample pictures and Dew Glass its own scene.
| Prop | Type | What it does |
|---|---|---|
| gallery | readonly { src: string; type?: "image" | "video"; alt?: string; focal?: readonly [number, number] }[] | The pictures and clips on the reel. URLs of JPG, PNG or WebP pictures and MP4 or WebM clips, on your own site or on a server that allows it (CORS). Left out, it shows its own sample pictures. |
| backgroundImage | string | The picture behind the glass. A URL to a JPG, PNG or WebP up to 10 MB, on your own site or on a server that allows it (CORS). It is shown as soon as it loads (backgroundMode switches to image unless you set it); left out, the shader shows its own scene. |
Chromatic Vapor, Cymatic Dust, Dew Glass, Glass Medusae, Glass Reel, Prismatic Caustics and Watercolor run a simulation or draw a mesh, in several passes. Their components carry those passes, so they install like any other shader.
Next.js and server rendering
The components are marked "use client". In the App Router, import one straight into a server component page or layout: no dynamic() and no ssr: false are needed. The page renders on the server and the shader starts in the browser, where WebGPU is. The Pages Router works the same way.
Blocks
A block is a whole section wearing a shader. Shape it on its page with Customize, then open Install, choose React and download it. The README in the download has the install line for the packages it uses.
Unzip it into components/aperveil/ and render it from its entry file. Every prop is optional: content overrides any line of the copy, design the colours and typefaces, shader the shader's values, and on a form block onSubmit makes the form live. The entry file imports the block's stylesheet; the Next.js Pages Router accepts global CSS in pages/_app.tsx only, so move that import there.
Troubleshooting
- Nothing appears.
- Give the surface a width and a height: the canvas fills its box, and a box without a height is zero pixels tall.
- The fallback shows instead.
- The browser has no WebGPU, or no usable GPU adapter, or the page is not served over HTTPS (localhost is fine). Keep important content in HTML, outside the shader.
- A value is ignored.
- An invalid value (a mistyped colour, an unknown option, a number out of range) keeps the default and logs one warning in the console. Numbers outside their range are clamped.
- The video does not play.
- A clip on another server must allow it (CORS). A clip on your own site always does.
Color Looks, browser support, performance and access are the same on every platform: see the overview.