Cloudflare Workers, D1 and R2

CCCFreemium

Infra · Build

Edge compute, a SQLite database and S3-compatible storage under one CLI, with a generous free tier.

What it is

Cloudflare Workers run JavaScript, TypeScript and Wasm on Cloudflare's edge, close to the visitor, with cold starts measured in milliseconds. Around the runtime sits a set of bindings you declare in wrangler.toml and use as plain objects in code: D1 (a serverless SQLite database with migrations and read replication), R2 (object storage with an S3-compatible API and no egress fees), KV, Queues, Durable Objects for stateful coordination, cron triggers, Workers AI, and Access for putting a login wall in front of anything. wrangler is the CLI for local dev, migrations, secrets and deploys.

The free plan covers a real amount of traffic and storage; paid usage is metered per request, per row read and per gigabyte stored. For a one-person or ten-person company this is the difference between running a product and running a Kubernetes cluster.

Where it fits in the AI OS

Build, the runtime for everything you ship: the website, the API worker, the Telegram bot, the cron that refreshes GitHub stars. Because every piece is a small deployable unit with typed bindings, it is also the environment agents are best at working in: one file, one config, one command to deploy.

Insider notes

members

How Serge's stack uses it

The membership site runs on it entirely: apps/web (Next.js via OpenNext) and apps/core (a Hono worker for membership logic) deploy as Workers, with D1 for the data model in the spec and R2 for media (an ideas-media bucket for clips, posters and screenshots, served through a CDN hostname with tier checks). Staging lives on stage.bulaev.ai through Worker custom domains. The live bulaev.ai site and Serge's earlier Telegram bot factory use the same Workers + D1 + R2 pattern, and Punctual, the open-source scheduler from his company, runs on it too.

Setup in 5 minutes

  1. npm create cloudflare@latest my-worker and pick the Hello World template; npx wrangler login.
  2. npx wrangler d1 create my-db, paste the binding into wrangler.toml, write migrations/0001_init.sql, run npx wrangler d1 migrations apply my-db --local.
  3. npx wrangler r2 bucket create my-media, add the R2 binding.
  4. In src/index.ts read from env.DB.prepare(...) and env.MEDIA.get(key); npx wrangler dev to test locally.
  5. npx wrangler deploy, then npx wrangler secret put API_KEY for anything sensitive.

Alternatives

  • Vercel + Neon/Turso + S3 — the other default for Next.js; more moving parts, more vendors.
  • Fly.io / Railway — containers with volumes when you need long processes or Postgres.
  • Deno Deploy / Supabase Edge Functions — edge functions with their own data stories.
  • AWS Lambda + DynamoDB + S3 — the enterprise version of the same idea, with the enterprise setup cost.