> ## Documentation Index
> Fetch the complete documentation index at: https://glassen.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Render your first glass lens

> Install Glassen and render a glass lens over a canvas.

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

```sh theme={null}
npm install glassen
```

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.

```html theme={null}
<div class="goop-orb" id="lens" style="width:320px" role="group" tabindex="0" aria-label="Glass lens. Drag or use arrow keys to stretch.">
  <canvas aria-hidden="true"></canvas>
</div>
```

```js theme={null}
import { createGlass, initGlass } from 'glassen'
import wasmUrl from 'glassen/wasm/goo_core_bg.wasm?url'
import 'glassen/style.css'

await initGlass(wasmUrl)
const image = document.createElement('canvas')
image.width = image.height = 128
const pen = image.getContext('2d')
pen.fillStyle = '#e84040'
pen.fillRect(32, 32, 64, 64)
const source = { sample: () => ({ image, version: 1 }) }
const lens = await createGlass(document.querySelector('#lens canvas'), {
  source,
  appearance: 'light',
})

// When removing the lens:
// lens.destroy()
```

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](https://glassen.mintlify.site/surfaces.md) use one canvas and clock for many lenses.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.