Cloudflare Developer Platform Handbook
A handbook on the Cloudflare developer platform: Workers, D1, R2, KV, Queues, Durable Objects, Workers AI, Vectorize. Written from building this blog, not a docs rehash.
20 posts · ~1 post/week · RSS
- 01 What the Cloudflare developer platform actually is
Cloudflare is no longer just a CDN. Workers, D1, R2, KV, Queues, DOs, Workers AI, and Vectorize form an edge-native platform. The mental model, contrasted with Lambda.
- 02 Workers runtime mental model: lifecycle, context, limits
The fetch handler, ExecutionContext, waitUntil, subrequest limits, CPU vs wall time, real cold starts. Six misconceptions from Node/Lambda. Code samples from this blog's Worker.
- 03 The 3-binding mental model: Request, Identity, Storage
A common frame for every Worker: Request is the entry point, Identity is who's calling, Storage is where you read and write. Applied to the Worker running this blog.
- 04 Wrangler + Miniflare dev loop: init to deploy in 30 minutes
The practical dev loop for Workers: wrangler init, local wrangler dev with Miniflare, vitest, D1 migrations, secrets, deploying to 300+ PoPs in 30 seconds. Plus CI/CD and gotchas.
- 05 KV deep-dive: global cache, eventual consistency, KV vs D1
Cloudflare KV is an eventually-consistent KV store with per-PoP caching. The real consistency model, limits that matter, 5 good patterns, 3 anti-patterns, and real gotchas.
- 06 D1 in production: primary-replica, batch, and 7 gotchas
D1 is SQLite at the edge with a primary region and read replicas: architecture, the 5 query methods, Sessions API, prepared-statement cache, and 7 production gotchas.
- 07 R2 object storage: S3-compat, zero egress, and 4 access patterns
R2 is Cloudflare's S3-compatible object storage with no egress fees. R2 vs S3 in real costs, 4 access patterns, S3 migration, and gotchas around consistency, metadata, lifecycle.
- 08 Queues and Durable Objects: async messaging and state
Two of the hardest Worker primitives. Queues for fire-and-forget jobs with retry and DLQ. Durable Objects for single-writer coordination. When to pick which, with real patterns.
- 09 Picking a Worker router: vanilla, Itty, or Hono
Three options: vanilla fetch (0 bundle), Itty Router (3KB), Hono (13KB). Syntax, middleware, Zod validation, when to pick which, and why this blog uses vanilla at 40+ routes.
- 10 ORMs for D1: Drizzle, Prisma, or raw SQL
Three choices: raw SQL (0KB), Drizzle (10KB, TS-first), Prisma (500KB WASM). Workflow, complex queries, migrations, type safety, and when an ORM costs more than it helps.
- 11 Astro, Remix, SvelteKit on Workers: adapters and trade-offs
Three full-stack frameworks on Workers differ in rendering, default JS, adapter, bindings. Real setup for each, SSG vs SSR vs hybrid, and why this blog picked Astro.
- 12 CI/CD with Wrangler + GitHub Actions: pipeline, smoke tests
A 4-step pipeline: test → build → deploy → smoke. Scoped API token, 19-assertion smoke test, concurrent lock, preview envs, 10-second rollback. Full workflow file from this blog.
- 13 Workers AI + AI Gateway: catalog, pricing, vs Bedrock/OpenAI
Workers AI on edge GPUs, AI Gateway proxying OpenAI/Anthropic/Bedrock/Google with cache + rate limit + observability. Catalog, pricing, when to use which, retry/fallback.
- 14 Vectorize + RAG: embeddings, top-K, hybrid from markdown
Vectorize is Cloudflare's native vector DB, paired with Workers AI bge-m3 for full-edge RAG. Ingest + query pipelines, chunking, metadata, hybrid search with D1, reranking.
- 15 Durable Objects for realtime: chat, collab, game state
Durable Objects are Cloudflare's single-writer primitive: 1 roomId = 1 instance, WebSocket Hibernation, persistent storage. 6 patterns, the API, and when DOs are overkill.
- 16 Stream + Images: edge media pipelines on Cloudflare
Cloudflare's 3 media products: Stream (video, HLS/DASH), Images (upload-transform-deliver), and Image Resizing / cf.image. Pipelines, pricing, and when to pick which.
- 17 Worker observability: Logs, Tail Workers, Analytics
Cloudflare's 4 observability layers: Workers Logs (3-day retention), Tail Workers (realtime), Logpush (batch to R2/SIEM), Analytics Engine. Structured logging, alerts, debugging.
- 18 Worker security: secrets, CSP, Bot Management, Turnstile
Defense-in-depth for Cloudflare Workers: WAF + Bot Management, Turnstile, Access JWT, secret management, CSP/HSTS, 4 auth patterns, Zod validation, and anti-patterns to avoid.
- 19 Cloudflare Developer Platform cost model: tiers vs AWS
Per-primitive Cloudflare pricing (Workers, D1, KV, R2, Queues, DOs, Vectorize, Workers AI), tier breakpoints, AWS comparison, and 3 scale scenarios from blog to 100M req/month.
- 20 Migrating AWS/Vercel to Cloudflare: a real playbook
Playbook for migrating a production app from AWS (Lambda, DynamoDB, RDS, S3, SQS, ElastiCache) to Cloudflare: per-primitive mapping, 3 strategies, cutover, rollback, 10 pitfalls.