Skip to main content

cf-common

CI npm npm downloads Bundle size License: MIT

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.

  • Typed end-to-end — strict types over every binding; no any at the edges.
  • Tree-shakeable — named subpath exports; import only the service you use.
  • Thin, not a framework — a convenience layer, never a wrapper you fight.
  • Workers-native — pure helpers over the runtime APIs you already have.

Install​

npm install @rtorcato/cf-common

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

Status​

Foundations and storage are published; the rest land incrementally — track progress in the roadmap, the Beta milestone, and the issues list.

AreaModulesStatus
Foundationserrors, env✅ Shipped
Storagekv, r2, r2-presign, d1, cache✅ Shipped
Web essentialshttp, request, assets🚧 Beta target (assets shipped)
Messaging & Computequeues, do, ws, rpc, cron, workflowsPlanned (queues, do, ws, rpc, cron, workflows shipped)
Security & authaccess, turnstile, ratelimitPlanned (access, ratelimit, secrets shipped)
AI & Dataai, vectorize, hyperdrive, ai-gatewayPlanned (ai, vectorize, hyperdrive, ai-gateway shipped)
Integrationsemail, analytics, images, browser, pipelinesPlanned (email, analytics, images, browser, pipelines shipped)
REST API clientapi✅ Shipped

See the API Reference for the shipped modules.

Design principles​

  • Thin over a service, never a framework. Each module covers one Cloudflare binding. If something needs heavy machinery, reach for a dedicated library.
  • Subpath imports are the contract. You always import from @rtorcato/cf-common/<module> so tree-shaking is automatic.
  • Strict TS, no implicit any in public APIs. Generic helpers preserve narrow types through the call.

Next steps​

  • Getting started — install and wire your first binding.
  • Examples — KV caching, R2 uploads, D1 queries, and a runnable Worker.
  • Roadmap — what ships when.

Project​