Fluorite
React package

Hooks

useShader for headless embeds, useShaderNode for R3F, and the error codes.

useShader

Like <Shader>, but you provide the markup:

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

const { state, error, backend, animated, containerRef, canvasRef, refresh } =
  useShader(id);
// attach containerRef to a positioned wrapper and canvasRef to a <canvas>

It takes the same options as <Shader> and returns:

FieldTypeNotes
stateShaderStateSee the states below
errorShaderError | nullSet when state is "error"
backend"webgpu" | "webgl" | nullWhich one is rendering
animatedbooleanWhether the shader changes over time
containerRef(el: HTMLElement | null)Attach to the wrapper element
canvasRef(el: HTMLCanvasElement | null)Attach to a <canvas>
refresh() => voidCheck for a new version now

States: idle, fetching, compiling, ready, paused (when play says not to run) and error.

useShaderNode

For React Three Fiber: gives you the shader to use in your own material. See the guide.

const { node, state, error, animated } = useShaderNode(id, {
  client,
  output,
});

Pass output to use one of the shader's named outputs instead of its main one.

Error codes

Errors are a ShaderError with a code and a retryable flag. Check the code, not the message.

CodeMeaning
NOT_FOUNDNot published, or no such version or shader
NETWORKThe request failed
INVALID_GRAPHThe graph could not be rendered
UNSUPPORTED_SCHEMAThe shader needs a newer version of the package
UNSUPPORTED_DEVICENeither WebGPU nor WebGL2 is available
CONTEXT_LOSTThe GPU context was lost
ASSET_FAILEDA texture failed to load
UNKNOWNAnything else

On this page