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

@alphablue/site-runtime

v0.1.0

Published

Edge injection of AlphaBlue live site state for Cloudflare Pages and Workers.

Readme

@alphablue/site-runtime

Edge injection of live site state for statically built sites on Cloudflare.

A static site has no code on the request path, so state that must take effect without a rebuild — a mourning grayscale, an announcement bar — has nowhere to be applied. This library provides the one place it can be: between the static asset and the browser, rewriting the built HTML as it streams.

Most sites will not use this directly. It is generated for you by @alphablue/astro-site.

Why not client-side JavaScript

Grayscale applied by a script means the browser paints the site in full colour first and greys it once the script arrives. For most features that is a blemish. The occasion for this one is royal mourning or a national disaster, where a flash of colour is a public discourtesy — and where a script that fails to load fails silently, with nobody finding out.

HTMLRewriter puts the attribute on the very first tag of the document, so the browser knows before it has parsed anything else.

Usage

Cloudflare Pages

// functions/_middleware.ts
import { applyLiveState } from "@alphablue/site-runtime";

export const onRequest: PagesFunction<Env> = async (ctx) =>
  applyLiveState(await ctx.next(), ctx.env);

Workers Static Assets

Use fetchAsset rather than env.ASSETS.fetch — see below.

// worker/index.ts
import { applyLiveState, fetchAsset } from "@alphablue/site-runtime";

export default {
  async fetch(request, env) {
    return applyLiveState(await fetchAsset(request, env), env);
  },
} satisfies ExportedHandler<Env>;

Both hosts need a LIVE_STATE KV binding and a SITE_ID var, and the site's CSS needs one rule:

html[data-mourning="1"] { filter: grayscale(1); }

Exported as MOURNING_CSS if you would rather inject it.

fetchAsset, and why it exists

Workers Static Assets sends an ETag for every file. State is applied after the asset is fetched, so a returning visitor's If-None-Match gets a 304 with no body — nothing to inject into — and their browser keeps showing the cached colour version. fetchAsset strips conditional validators from navigations only, so assets keep their caching.

Cloudflare Pages sends no validators for HTML, so this is unnecessary there.

Failure behaviour

If the KV read fails, the original response is returned untouched. This code runs in front of every page of every site using it; a content-service problem must not be able to take those sites offline.

License

MIT