Quick start
With the custom element
Section titled “With the custom element”Define <sk-shader> once, then use it anywhere on the page.
<script type="module"> import { defineShaderElement } from '@shadekit/element'; import { aurora } from '@shadekit/shaders/aurora'; import { styles } from '@shadekit/shaders/styles';
defineShaderElement({ aurora }, { styles });</script>
<sk-shader style="aurora-ember"></sk-shader>Two usage modes:
shader— run a registered engine directly:<sk-shader shader="aurora" speed="0.4"></sk-shader>style— resolve a named preset (engine + uniforms) from thestylesregistry:<sk-shader style="aurora-ember"></sk-shader>
Any attribute matching one of the shader’s uniforms overrides the preset.
Values parse as floats or JSON arrays — see
<sk-shader> element.
With React
Section titled “With React”import { Shader } from '@shadekit/react';import { aurora } from '@shadekit/shaders/aurora';
export function Hero() { return <Shader shader={aurora} uniforms={{ speed: 0.4 }} />;}uniforms is reactive — pass a new object and the instance receives
updateUniforms() without re-mounting.
With the raw engine
Section titled “With the raw engine”import { ShaderInstance } from '@shadekit/core';import { aurora } from '@shadekit/shaders/aurora';
const instance = new ShaderInstance(aurora, { pointer: true });await instance.mount(document.querySelector('canvas'));
instance.updateUniforms({ speed: 0.4 });This is the same instance the element and React wrappers drive —
see @shadekit/core.