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

eleventy-plugin-cloudflare-kv

v1.0.2

Published

Eleventy plugin that builds collections from content stored in Cloudflare KV as a simple CMS.

Readme

npm version Node.js CI

eleventy-plugin-cloudflare-kv

An Eleventy plugin that builds collections from content stored in Cloudflare KV as a simple CMS.

Features

  • 🚀 Fetch content from Cloudflare KV at build time
  • 📝 Automatic Frontmatter parsing
  • 🏷️ Organize content into collections based on KV key name
  • ⚙️ Configurable metadata for each item
  • 🤫 Optional quiet mode for clean build output
  • 🔧 Flexible environment variable configuration

Installation

npm install eleventy-plugin-cloudflare-kv

Usage

Basic Setup

Add the plugin to your .eleventy.js configuration:

import kvCollectionsPlugin from "eleventy-plugin-cloudflare-kv";

export default function (eleventyConfig) {
  eleventyConfig.addPlugin(kvCollectionsPlugin, {
    metadata: {
      permalink: (itemData, itemKey, collectionName) => {
        return `/${collectionName}/${itemData.slug || itemKey}/`;
      }
    }
  });
}

Configuration Options

| Option | Type | Required | Description | | -------------------- | ------- | -------- | -------------------------------------------------------------------------------------- | | metadata | Object | No | Additional metadata to add to each item | | accountId | String | No | Environment variable name for Cloudflare Account ID (default: CLOUDFLARE_ACCOUNT_ID) | | namespaceId | String | No | Environment variable name for KV Namespace ID (default: CLOUDFLARE_KV_NS_ID) | | cloudflareAPIToken | String | No | Environment variable name for API Token (default: CLOUDFLARE_API_TOKEN) | | quiet | Boolean | No | Suppress console output except errors (default: false) |

Environment Variables

Set these environment variables in your build environment:

CLOUDFLARE_ACCOUNT_ID=your-account-id
CLOUDFLARE_KV_NS_ID=your-namespace-id
CLOUDFLARE_API_TOKEN=your-api-token

Or configure custom variable names:

eleventyConfig.addPlugin(kvCollectionsPlugin, {
  accountId: "MY_ACCOUNT_ID",
  namespaceId: "MY_KV_NAMESPACE",
  cloudflareAPIToken: "MY_API_TOKEN",
  metadata: {
    permalink: (itemData) => `/posts/${itemData.slug}/`
  }
});

KV Key Structure

The plugin organizes content into collections based on your KV key structure:

  • posts/hello-world → Collection: posts, Item key: hello-world
  • pages/about → Collection: pages, Item key: about
  • standalone → Collection: none, Item key: standalone

Content Format

Store your content in KV with front matter:

---
title: "Hello World"
date: 2024-01-01
slug: "hello-world"
tags: ["post", "greeting"]
---

# Hello World

This is my first post stored in Cloudflare KV!

Advanced Configuration

eleventyConfig.addPlugin(kvCollectionsPlugin, {
  metadata: {
    permalink: (itemData, itemKey, collectionName) => {
      if (!itemData.permalink) {
        if (!itemData.title || !itemData.date) {
          throw new Error(`Unable to generate permalink for item: ${itemKey}`);
        }
        const date = new Date(itemData.date);
        const year = date.getFullYear();
        const slug = itemData.slug || itemKey;
        return `/${collectionName}/${year}/${slug}/`;
      }
      return itemData.permalink;
    },
    layout: "post.njk",
    collection: (itemData, itemKey, collectionName) => collectionName
  },
  quiet: true
});

API

Metadata Functions

Metadata values can be either constants or functions that receive:

  • itemData: The parsed content and front matter data
  • itemKey: The item's key derived from the KV key
  • collectionName: The collection name derived from the KV key

Requirements

  • Node.js 20+
  • Eleventy 2.0+
  • Cloudflare KV namespace with API token

Contributing

Issues and pull requests are welcome on GitHub at https://github.com/alexmensch/eleventy-plugin-cloudflare-kv.