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

@rtorcato/cf-common

v1.5.2

Published

Typed TypeScript wrappers and helpers for working with Cloudflare bindings and APIs.

Readme

cf-common

npm docs license

Typed TypeScript wrappers and helpers for working with Cloudflare bindings and APIs — in the spirit of js-common and browser-common.

Each module is a thin, well-typed convenience layer over a Cloudflare service — not a framework. Tree-shakeable subpath exports, zero required runtime dependencies, built for the Workers (workerd) runtime.

Install

pnpm add @rtorcato/cf-common

Requirements: a Cloudflare Workers project (Wrangler). TypeScript ≥ 5.0 is recommended — every public API ships with strict types and JSDoc.

Quick start

import { getBinding, requireEnv } from '@rtorcato/cf-common/env'
import { createKvStore } from '@rtorcato/cf-common/kv'
import { toCloudflareError } from '@rtorcato/cf-common/errors'

interface User {
  id: number
  name: string
}

export default {
  async fetch(req: Request, env: Record<string, unknown>): Promise<Response> {
    try {
      // Throws a 500 if the binding is missing — a deploy misconfiguration,
      // not a client error.
      const users = createKvStore<User>(getBinding(env, 'USERS'))

      const user = await users.get('u:42') // User | null, JSON-parsed
      if (!user) return Response.json({ error: 'Not found' }, { status: 404 })

      return Response.json(user)
    } catch (err) {
      const e = toCloudflareError(err)
      return Response.json(
        { error: e.expose ? e.message : 'Internal error', code: e.code },
        { status: e.status }
      )
    }
  },
}

Modules

Each module is a separate subpath import, so you ship only what you use.

| Subpath | Description | Status | | --- | --- | --- | | @rtorcato/cf-common/errors | CloudflareError (HTTP status + expose + code), isCloudflareError, toCloudflareError | ✅ Shipped | | @rtorcato/cf-common/env | getBinding, requireEnv, getEnv — typed access to Worker bindings and vars | ✅ Shipped | | @rtorcato/cf-common/kv | createKvStore — typed JSON get/put/delete/list with TTL + metadata | ✅ Shipped | | @rtorcato/cf-common/r2 | createR2Store + multipartUpload — object helpers and a multipart driver | ✅ Shipped | | @rtorcato/cf-common/d1 | query/queryFirst/execute/batch + idempotent runMigrations | ✅ Shipped |

More land incrementally (HTTP, Request, Queues, Durable Objects, Cache, Workers AI, …). See the milestones for the roadmap, or the Beta milestone for what's next.

Documentation

Full docs and the per-module API reference live at rtorcato.github.io/cf-common.

Development

pnpm install
pnpm verify        # typecheck + biome + tests
pnpm build         # tsup → dist/ (ESM, per-module subpaths)
pnpm test:watch    # vitest in watch mode

Commits follow Conventional Commits; releases are cut automatically by semantic-release.

License

MIT © Richard Torcato