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

@frapx/react-canvas

v0.4.0

Published

React bindings for @frapx/fx-canvas.

Readme

@frapx/react-canvas

npm version

React bindings for @frapx/fx-canvas.

This package is a thin lifecycle adapter. It does not replace the core render loop with React state, and it does not ship CSS.

Install

pnpm add @frapx/fx-canvas @frapx/react-canvas react

Component

import { ShaderBackground } from "@frapx/react-canvas";
import { glsl } from "@frapx/fx-canvas";

const fragment = glsl`
precision highp float;
uniform vec2 u_resolution;
uniform float u_time;

void main() {
  vec2 uv = gl_FragCoord.xy / u_resolution;
  gl_FragColor = vec4(uv, 0.5 + 0.5 * sin(u_time), 1.0);
}
`;

export function HeroBackground() {
  return <ShaderBackground fragment={fragment} className="hero-bg" />;
}

The component renders a wrapper div and mounts the shader canvas into it. The wrapper defaults to position: relative and overflow: hidden; layout, height, and visual styling are controlled by your app.

Core shader options pass through as props, including feedback:

<ShaderBackground fragment={feedbackFragment} feedback />;

Initialization options such as fragment, vertex, feedback, renderMode, dpr, and canvas settings recreate the underlying shader instance when they change. Runtime uniforms and textures update the existing instance.

Hook

import { useMemo } from "react";
import { useShaderBackground } from "@frapx/react-canvas";

export function ShaderPanel({ intensity }: { intensity: number }) {
  const uniforms = useMemo(() => ({ intensity }), [intensity]);
  const { ref, instance, error } = useShaderBackground(
    {
      fragment,
      uniforms,
      feedback: true
    },
    [fragment, true]
  );

  return <div ref={ref} />;
}

Pass recreation dependencies as the second argument. uniforms and textures are updated on the existing instance with setUniforms() and setTextures(); shader source and other initialization options, including feedback, should be included in the recreation dependency array when they change.

Imperative Handle

import { useRef } from "react";
import {
  ShaderBackground,
  type ShaderBackgroundHandle
} from "@frapx/react-canvas";

const ref = useRef<ShaderBackgroundHandle>(null);

<ShaderBackground ref={ref} fragment={fragment} />;

ref.current?.stop();
ref.current?.start();
ref.current?.setUniform("intensity", 1);

The handle forwards commands to the latest shader instance, so it remains useful when React recreates the underlying runtime.

Notes

  • React 18 and newer are supported.
  • The package is safe to import during SSR; WebGL work starts only after mount.
  • React StrictMode double mounting is handled by destroying the previous runtime in effect cleanup.
  • Keep uniforms and textures stable with useMemo when they are derived from React state.
  • onShaderReady and onShaderError are used instead of core onReady and onError to avoid DOM prop naming conflicts.