Installation
All packages are ESM-only and marked sideEffects: false, so bundlers
tree-shake every engine you don’t import. Works with pnpm, npm,
yarn, or bun — examples use pnpm.
Which packages
Section titled “Which packages”| Path | Packages |
|---|---|
| React app | @shadekit/react + @shadekit/shaders |
| Everything else | @shadekit/element + @shadekit/shaders |
| Your own wrapper / direct canvas control | @shadekit/core + @shadekit/shaders |
@shadekit/element and @shadekit/react already depend on
@shadekit/core — installing them pulls the engine transitively.
Dedicated wrappers other than React aren’t shipped yet; the
<sk-shader> custom element covers every framework that renders
standard DOM elements.
Per-framework setup
Section titled “Per-framework setup”pnpm add @shadekit/react @shadekit/shadersimport { Shader } from '@shadekit/react';import { aurora } from '@shadekit/shaders/aurora';
export function Hero() { return ( <div style={{ height: '20rem' }}> <Shader shader={aurora} uniforms={{ speed: 0.4 }} pointer /> </div> );}uniforms is reactive — a new object updates in place without
remounting. Full props: @shadekit/react.
Next.js App Router: add 'use client' to the file using <Shader>
(it uses hooks). SSR is safe — the instance mounts in useEffect, so
nothing renders on the server.
pnpm add @shadekit/element @shadekit/shadersRegister once in main.ts before mounting the app:
import { defineShaderElement } from '@shadekit/element';import { aurora } from '@shadekit/shaders/aurora';import { styles } from '@shadekit/shaders/styles';
defineShaderElement({ aurora }, { styles });<template> <sk-shader style="aurora-ember" class="shader-block"></sk-shader></template>Two Vue-specific notes:
-
Tell Vite the tag is a native element, not a component, or you’ll get an unresolved-component warning:
vite.config.ts vue({ template: { compilerOptions: {isCustomElement: (tag) => tag.startsWith('sk-'),} } }) -
The preset attribute is literally named
style. To size the element, use aclassor a wrapper<div>— neverstyle="…"on the tag itself, or the preset lookup fails.
pnpm add @shadekit/element @shadekit/shaders<script> import { onMount } from 'svelte';
onMount(async () => { const { defineShaderElement } = await import('@shadekit/element'); const { aurora } = await import('@shadekit/shaders/aurora'); const { styles } = await import('@shadekit/shaders/styles'); defineShaderElement({ aurora }, { styles }); });</script>
<sk-shader style="aurora-ember" class="shader-block"></sk-shader>The onMount + dynamic-import pattern is required under SvelteKit —
customElements doesn’t exist during SSR, so top-level registration
crashes server-side. In a pure client Svelte app a plain top-level
import in the component or main.ts is fine.
pnpm add @shadekit/element @shadekit/shadersimport { onMount } from 'solid-js';import { defineShaderElement } from '@shadekit/element';import { aurora } from '@shadekit/shaders/aurora';import { styles } from '@shadekit/shaders/styles';
export function Hero() { onMount(() => defineShaderElement({ aurora }, { styles })); return <sk-shader style="aurora-ember" class="shader-block" />;}Solid renders <sk-shader> as a native element (dash-cased tags pass
through). onMount keeps registration off the server under SolidStart.
Setting attributes later via el.setAttribute updates uniforms live —
see <sk-shader> element.
pnpm add @shadekit/element @shadekit/shadersimport { useEffect } from 'preact/hooks';import { defineShaderElement } from '@shadekit/element';import { aurora } from '@shadekit/shaders/aurora';import { styles } from '@shadekit/shaders/styles';
export function Hero() { useEffect(() => { defineShaderElement({ aurora }, { styles }); }, []); return <sk-shader style="aurora-ember" class="shader-block" />;}Preact treats <sk-shader> as a native element — attributes pass
straight through to the DOM.
pnpm add @shadekit/element @shadekit/shadersRegister in main.ts:
import { defineShaderElement } from '@shadekit/element';import { aurora } from '@shadekit/shaders/aurora';import { styles } from '@shadekit/shaders/styles';
defineShaderElement({ aurora }, { styles });Angular templates need CUSTOM_ELEMENTS_SCHEMA or the unknown tag is a
compile error:
@Component({ standalone: true, schemas: [CUSTOM_ELEMENTS_SCHEMA], template: `<sk-shader style="aurora-ember" class="shader-block"></sk-shader>`,})export class HeroComponent {}pnpm add @shadekit/element @shadekit/shaders<sk-shader style="gradient-dusk" class="shader-block"></sk-shader>
<script> import { defineShaderElement } from '@shadekit/element'; import { gradient } from '@shadekit/shaders/gradient'; import { styles } from '@shadekit/shaders/styles'; defineShaderElement({ gradient }, { styles });</script>Astro ships <script> to the browser automatically — no SSR guard
needed, and registration is idempotent so a shared layout can define it
once.
pnpm add @shadekit/element @shadekit/shadersimport { component$, useVisibleTask$ } from '@builder.io/qwik';
export const Hero = component$(() => { useVisibleTask$(async () => { const { defineShaderElement } = await import('@shadekit/element'); const { aurora } = await import('@shadekit/shaders/aurora'); const { styles } = await import('@shadekit/shaders/styles'); defineShaderElement({ aurora }, { styles }); }); return <sk-shader style="aurora-ember" class="shader-block" />;});useVisibleTask$ runs browser-only and lazily — the engine code doesn’t
load until the element scrolls into view, which is exactly what you want
for a background effect.
pnpm add @shadekit/element @shadekit/shaders<sk-shader style="starfield-mono" class="shader-block"></sk-shader>
<script type="module"> import { defineShaderElement } from '@shadekit/element'; import { starfield } from '@shadekit/shaders/starfield'; import { styles } from '@shadekit/shaders/styles'; defineShaderElement({ starfield }, { styles });</script>No framework at all — this is the same mechanism every tab above uses. If your stack renders HTML and runs module scripts, it works.
Sizing the element
Section titled “Sizing the element”<sk-shader> renders a canvas stretched to 100% × 100% of the
element — the element itself must have a height. Give it a class or
wrapper; don’t use the style attribute for sizing (it carries the
preset name):
<div style="height: 24rem"> <sk-shader style="aurora-ember"></sk-shader></div>/* or a utility class */.shader-block { display: block; height: 24rem; }Server-side rendering
Section titled “Server-side rendering”customElements only exists in the browser. Under SSR (Next, Nuxt,
SvelteKit, SolidStart, Qwik) register inside the framework’s client-only
hook — useEffect, onMount, useVisibleTask$ — as shown in the tabs.
The <sk-shader> tag itself renders harmlessly as an empty element on
the server and upgrades on hydration.
Requirements
Section titled “Requirements”- A browser with WebGPU or WebGL2 —
backend: 'auto'(the default) prefers WebGPU and falls back automatically. See Backends. - TypeScript types ship with every package.