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

@ascii-fx/react

v0.6.0

Published

React components and hooks for ASCII FX: <AsciiImage>, <AsciiVideo>, <AsciiCanvas> with SSR-safe fallbacks.

Readme

@ascii-fx/react

Drop-in ASCII rendering for React: <AsciiImage>, <AsciiVideo>, <AsciiCanvas>, and the hooks underneath them.

pnpm add @ascii-fx/react
import { AsciiImage } from '@ascii-fx/react'

;<AsciiImage src="/cat.jpg" alt="Cat" />

No profile, no config, no setup. It compiles a monospace profile at runtime, renders on the GPU where there is one, and falls back to the exact CPU matcher where there isn't. Precompiled profiles via @ascii-fx/vite are faster and deterministic, but they're an optimisation, not a prerequisite.

What renders before the canvas does

The server renders the real <img> or <video> — correct alt, correct dimensions, no wrapper hacks — and the client fades the canvas in over it once matching succeeds. The fallback element stays in the layout and in the accessibility tree the whole time, so:

  • no-JS gets the actual image
  • no-WebGPU gets the CPU matcher, and if that fails too, still the actual image
  • a slow load or a hard failure degrades to the actual image
  • there's no layout shift and no flash, because nothing is ever absent

alt is required by the type on <AsciiImage>. Use alt="" for decorative images, deliberately.

When it fails

A renderer that can't be built is invisible by design — the fallback is already on screen and simply stays there. onError is how your app finds out:

<AsciiVideo src="/clip.mp4" onError={(e) => reportToSentry(e)} autoPlay muted loop />

It fires once per distinct failure, for a failed init and for a GPU device loss that couldn't be recovered from.

Painting the source

The matcher is exact about the pixels it is handed and owns nothing upstream of them, so pixel effects — a contrast curve, grain, a channel shift — are not renderer options. They go on the source, and draw is where:

<AsciiImage src="/portrait.jpg" alt="A portrait" columns={120} draw={drawGrain} animate fps={10} />

draw(ctx, { image, width, height }, timeMs) gets a 2D context over a buffer the image's natural size, so fit, columns and everything else behave exactly as they do without it. Nothing is painted into it for you — draw the image first if you want it there.

One rule decides whether an effect survives the grid: a cell fits a single colour to width / columns source pixels, so anything finer than that arrives as its share of the average instead of as itself. Grain at 1px on a 2000px-wide image at 120 columns is invisible; the same grain in ~16px blocks is not.

animate re-runs draw on a loop throttled to fps (default 12, not the display rate — every frame is a full re-match). Without it an image is matched once and left, which is why a still costs nothing per frame.

Motion and cost

prefers-reduced-motion disables autoplay, interactions and the animate loop while keeping a static frame. Rendering pauses when the component scrolls offscreen or the tab is hidden. Both are on by default; respectReducedMotion and pauseWhenOffscreen turn them off.

Hooks

const { renderer, profile, error, canvasKey } = useAscii(canvasRef, { profile, columns: 120 })

canvasKey is the important one: put it on your <canvas key={canvasKey}>. It changes when the canvas has to be thrown away and remade — a backend switch, or a device loss the renderer couldn't recover from — because a canvas is bound to its first context type for good, so one that ran WebGPU can never fall back to 2D.

Also useAsciiProfile, useAsciiSupport, and usePrefersReducedMotion.

RSC and Next

Every file ships the 'use client' directive, so the components work in the App Router without a wrapper. The package is side-effect free and ESM-only.

License

MIT