APERVEIL / DOCS / REACT

Aperveil for React

Next.js, Vite and any React 18.2+ app: a typed component per shader, set with props.

01

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.

terminal
npm install ./vendor/aperveil-runtime-0.1.1.tgz ./vendor/aperveil-react-0.1.1.tgz
02

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.

Hero.tsx
"use client";

import DotGrid from "./DotGrid";

export default function Hero() {
  return (
    <DotGrid
      className="hero-shader"
      density={72} background="#0d1017ff"
      fallback={<div className="hero-shader-fallback" />}
    />
  );
}

// .hero-shader { width: 100%; height: 560px; }

Keep headings, links and anything important in HTML above or beside the shader: the canvas is a visual layer, not your document.

03

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:

PropTypeWhat it does
classNamestringSize and place the surface. The canvas fills this box, so give it a width and a height.
styleCSSPropertiesInline styles for the surface box.
pausedbooleanHolds the current frame. Use it for a pause control or for sections scrolled out of view.
fallbackReactNodeShown instead of the canvas without WebGPU. Also shown if rendering fails. A poster image or a CSS gradient works well.
onReady() => voidThe first frame has been drawn.
onError(error: unknown) => voidRendering failed; the fallback is shown.
04

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.

VideoHero.tsx
import ThermalVision from "./ThermalVision";

export default function VideoHero() {
  return (
    <ThermalVision
      className="hero-shader"
      src="/videos/your-clip.mp4"
      mediaFocus={[0.5, 0.4]}
    />
  );
}
PropTypeWhat it does
srcstringThe 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.
mediaFocusreadonly [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.

PropTypeWhat it does
galleryreadonly { 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.
backgroundImagestringThe 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.

05

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.

06

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.

page.tsx
import SignatureHeroSection from "@/components/aperveil/signature-hero";

export default function Page() {
  return <SignatureHeroSection />;
}

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.

07

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.