Skip to content

@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
  • Uniforms are the reactive seam. Passing a new uniforms object updates values without destroying the instance or pipeline. Pass a stable reference (e.g. useMemo) if you don’t want a per-render diff.
  • shader identity controls mount lifecycle. Swapping to a different definition tears down and remounts — swap uniforms, not shader, for preset changes on the same engine.
  • paused is driven declaratively — unlike the raw instance where you call pause()/play() yourself.
  • The canvas unmounts cleanly on component teardown — the instance’s destroy() removes listeners and frees the ticker slot.

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} />