npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@shader-core/svelte

v1.0.0

Published

Svelte action for Shader Core: use:shader on a canvas, with the stack as data.

Readme

@shader-core/svelte

A Svelte action for Shader Core: an animated WebGL2 background composed from layers that stack.

npm install @shader-core/svelte

Svelte 3, 4 and 5 all take it. It is a plain function, so there is nothing to compile and no .svelte file in the package.

Use

<script>
  import { shader } from '@shader-core/svelte';
  import gradient from '@shader-core/layers/gradient';
  import curtains from '@shader-core/layers/curtains';
  import grain from '@shader-core/layers/grain';

  let intensity = $state(0.05);
</script>

<canvas
  style="position: fixed; inset: 0; z-index: -1; display: block; width: 100%; height: 100%"
  use:shader={{
    stack: [
      { layer: gradient, colorA: '#04060f', colorB: '#0a1230' },
      { layer: curtains, scale: 3.8, colorSheet: '#3ddc97' },
      { layer: grain, intensity },
    ],
  }}
></canvas>

The stack is data: layers bottom to top, each with its params and colours flat beside it, the same shape @shader-core/js takes. Anything left out keeps the layer's default, including the blend it was designed for.

It is reactive the way any action parameter is. Change a value — intensity above — and a uniform moves. Add, remove or reorder a layer and the stack recompiles once, then it is cached.

The canvas is yours, so size it: a canvas is inline and 300×150 until told otherwise.

Why an action, not a component

React and Vue hand a component its children as data, which is how their <Shader> reads a stack out of layer children without rendering them. Svelte does not — a slot or a snippet renders, it does not describe — so a <Shader> with layer children would have to mount each layer to learn what it was. An action, handed the canvas and the stack, is the direct way to say the same thing.

Parameters

| Parameter | What it does | | --------------- | ----------------------------------------------------------------------------------------------- | | stack | The layers. An empty stack is allowed; the renderer starts with the first one that has a layer. | | paused | Stops the animation and keeps everything else. Unset it to resume. | | quality | auto (default), high or low. Caps the pixel budget on modest hardware. | | reducedMotion | static (default) or animate, under prefers-reduced-motion. | | staticTime | Renders one frame at this time, in seconds, and never animates. | | onError | Called for anything that goes wrong. Without it, errors go to the console. |

quality, reducedMotion and staticTime are read when the action starts. They belong to the GL context, and a canvas cannot get a context back once it has been released, so changing one means a new canvas — wrap it in {#key quality}…{/key}. The stack and paused are live.

A background is not worth taking a page down for: a device with no WebGL2, or a layer that will not compile, is reported and leaves the canvas blank rather than throwing.

Layers

Every layer is its own module under @shader-core/layers/<id> — gradient, mesh, silk, sheen, glow, ribbon, grain, tone and the rest; the editor exports this code for any stack you build. Import only what you use.

Licence

Free to use, including commercially, on one condition: the credit comment stays in shader source you copy. Full terms in LICENSE.md.