Skip to main content
Glassen takes a canvas and a source of pixels. This example uses a small canvas so you can run it without external images, fonts or CORS configuration.

Install

Rendering needs WebGL 2 and WebAssembly. The package contains both WASM modules; the core import does not load nested physics or require React.

Render

With Vite, import the WASM URL explicitly. This also makes asset relocation visible to the bundler.
Keep space around the slot for stretch and shadow. The CSS paints beyond the slot; an ancestor with overflow: hidden clips it. The renderer’s goop-orb class names are internal names retained from the original host.

Other bundlers and plain modules

Call initGlass(urlOrBytes) before mounting when your bundler does not preserve the generated new URL(..., import.meta.url) asset. Copy the exported WASM to your application’s public assets and pass that URL. Serve it as application/wasm. Plain browser ESM can load it beside the package’s JS chunks without explicit initialization. Imports are safe during SSR. Call mount methods only in a browser lifecycle hook, and catch rejected initialization to display your application’s fallback. React handles its mount failures in the component. Shared surfaces use one canvas and clock for many lenses.