Fluorite
Guides

Embed in React

Render a shader live in any React or Next.js app.

Install the package:

npm install @fluorite-studio/react three

Publish the shader first, since only published shaders can be embedded. Then add it by id. Copy the id, or the whole snippet, from the editor's Embed dialog:

import { Shader } from "@fluorite-studio/react";

export const Hero = () => (
  <Shader
    id="9f3c7b21-4d8e-4a10-9f2b-7c6d5e4f3a21"
    className="size-full rounded-xl"
  />
);

This shows your latest published version. To always show one version, pin it:

<Shader id="9f3c7b21-4d8e-4a10-9f2b-7c6d5e4f3a21" version="1.2.0" />

It works with server-side rendering.

Common props

PropTypeDefaultNotes
idstringrequiredShader id
versionstringlatestPin a published version
inputsRecord<string, …>noneValues for exposed inputs
play"visible" | "always" | "hover" | false"visible"When the animation runs
revalidatenumberoffCheck for new versions every N ms
revalidateOnFocusbooleanfalseCheck again when the window regains focus
dprnumber | [min, max][1, 2]Device-pixel-ratio clamp
maxFpsnumberuncappedThrottle the frame rate
forceWebGLbooleanfalseSkip WebGPU and render on WebGL2

See Components for the full list, including loading, fallback, error handling and styling hooks.

If you haven't pinned a version, revalidate={5000} picks up each new publish within five seconds.

Previewing before you publish

To see unpublished work in a real page, pass a preview token instead of a version:

<Shader
  id="9f3c7b21-4d8e-4a10-9f2b-7c6d5e4f3a21"
  draft={process.env.NEXT_PUBLIC_FLUORITE_PREVIEW_TOKEN!}
/>

Anyone who loads the page can see the token, so use this on previews and staging only.

On this page