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

cloudflare-assets-kv

v0.0.2

Published

A simple library to serve and dynamically update static assets from Cloudflare KV storage in your Workers.

Readme

cloudflare-assets-kv

A simple library to serve and dynamically update static assets from Cloudflare KV storage in your Workers.

Quick Start

1. Set up your wrangler.toml

Add an ASSETS_KV namespace to your wrangler.toml:

[[kv_namespaces]]
binding = "ASSETS_KV"
id = "your-kv-namespace-id"

2. Install the package

npm install cloudflare-assets-kv

3. Use the middleware in your Worker

import { withAssetsKV } from "cloudflare-assets-kv";

export default {
  fetch: withAssetsKV(
    async (request, env, ctx) => {
      // Your worker code here
      return new Response("Not Found", { status: 404 });
    },
    {
      excludePaths: ["/api/"], // Optional: paths to exclude from KV lookup
    },
  ),
};

4. Configure your asset sources

Create a .assetsignore file in your project root to exclude files and directories:

node_modules
.wrangler
.git
.DS_Store

Alternatively, place your assets in a public directory.

5. Add your static assets

Put your static assets in the project root (or public directory).

6. Upload assets to KV

npx uploadkv

Options:

  • --dryrun: Show what would be uploaded without uploading
  • --local: Use local KV storage for development

7. Dynamically update assets

You can read and write assets directly in your worker code:

// Read an asset
const asset = await env.ASSETS_KV.get("index.html", { type: "text" });

// Update an asset
await env.ASSETS_KV.put("index.html", newContent, {
  metadata: {
    contentType: "text/html",
    updated: new Date().toISOString(),
  },
});

Configuration Options

The withAssetsKV middleware accepts these options:

{
  kvNamespace: "ASSETS_KV", // KV namespace binding name
  excludePaths: [], // Paths to exclude from asset handling
  pathPrefix: "", // Path prefix to add when looking up assets in KV
  cacheControl: "public, max-age=31536000", // Cache control header value
  browserTTL: 31536000, // Browser cache TTL in seconds
  includeHost: false // Whether to include hostname in the KV key
}