@shadekit/react
A thin component over ShaderInstance. Props map to engine options;
uniforms is reactive.
import { Shader } from '@shadekit/react';import { aurora } from '@shadekit/shaders/aurora';
export function Hero() { return ( <Shader shader={aurora} uniforms={{ speed: 0.4, colors: [0.8, 0.3, 0.4] }} pointer className="hero-shader" /> );}The component renders a <canvas> stretched 100% × 100% — control
size on the parent.
| Prop | Type | Description |
|---|---|---|
shader |
ShaderDefinition |
The engine to run — changing it remounts the instance |
uniforms |
Record<string, UniformValue> |
Reactive — each change calls updateUniforms() in place |
className / style |
— | Applied to the canvas element |
paused |
boolean |
Reactive — true calls pause(), false calls play() |
...ShaderOptions |
— | backend, pointer, maxDpr, respectReducedMotion, frameBudget, onError — see @shadekit/core |
Behaviour notes
Section titled “Behaviour notes”- Uniforms are the reactive seam. Passing a new
uniformsobject updates values without destroying the instance or pipeline. Pass a stable reference (e.g.useMemo) if you don’t want a per-render diff. shaderidentity controls mount lifecycle. Swapping to a different definition tears down and remounts — swapuniforms, notshader, for preset changes on the same engine.pausedis driven declaratively — unlike the raw instance where you callpause()/play()yourself.- The canvas unmounts cleanly on component teardown — the instance’s
destroy()removes listeners and frees the ticker slot.
With the style presets
Section titled “With the style presets”styles presets are plain data — spread one into uniforms:
import { styles } from '@shadekit/shaders/styles';import { aurora } from '@shadekit/shaders/aurora';
const preset = styles['aurora-ember'];
<Shader shader={aurora} uniforms={preset.uniforms} />