Cloudflare Workers + D1 in production — the real-world build pattern
D1 hit production-ready in 2024 and matured fast. r/nextjs "Vercel CPU 3x slower" benchmark + Lempa's Cloudflare Workers content + r/CloudFlare 4-year SaaS tips frame the working stack.
D1 hit production-ready in 2024 and matured fast through 2025. By August 2025 the Workers + D1 stack was a credible alternative to “Vercel + managed Postgres” for a meaningful slice of new SaaS builds. Christian Lempa”s July 18 video — “Publish a Static Hugo Website the EASY way // Cloudflare Workers” — captured the broader “Cloudflare-as-default” sentiment that”s been building through 2025. The full-stack version (Workers compute + D1 storage + Workers Static Assets) became the same easy default for dynamic apps.
This guide is the working pattern from shipping two production SaaS apps on Workers + D1 through 2024-2025.
The community signal matters. The r/nextjs “Vercel Edge vs Cloudflare Workers: Vercel CPU 3x slower in my benchmark” thread (69 upvotes, Sep 29) — published 7 weeks after this article — captured the performance comparison that became a recurring discussion. The “drop your Vercel hosting replacements” thread (285 upvotes, Sep 30) — same week — captured the broader migration momentum. Cloudflare Workers wasn”t a hypothetical alternative anymore by Q3 2025; it was an active default for a growing share of new builds.
The minimum-viable Workers + D1 stack
The stack that works for typical SaaS:
Frontend: Static assets via Workers Static Assets
(or hybrid SSR via Workers + framework adapter)
Backend: Cloudflare Workers for API routes
Database: D1 (with read replicas if multi-region)
Storage: R2 for files / blobs
Cache: Workers KV for hot data, R2 for cold cache
Auth: Auth0 / Clerk / Lucia self-hosted
Email: Resend / Postmark
Payments: Stripe
Total monthly cost at small-to-medium scale: $5-50/mo for a typical SaaS app serving thousands of users. Compared to “Vercel Pro + Neon Pro + Vercel Blob storage + cache layer” running $80-300/mo for equivalent traffic, the savings are real.
What Workers + D1 actually wins at
After shipping two SaaS apps on the stack:
1. Cost predictability. Pricing is well-documented; surprise bills are rare (with reasonable usage). Compare to Vercel”s Active CPU pricing controversies.
2. Global latency by default. Workers run at the edge; D1 reads from nearest replica. Global users get acceptable latency without complex CDN setup.
3. The “static assets + dynamic compute” pattern is now first-class. Workers Static Assets handles your built frontend; Workers handle API routes. No separate hosting tier for static vs dynamic.
4. Vendor concentration in good ways. One bill, one dashboard, one operational model. Cloudflare Workers + D1 + R2 + KV is operationally simpler than equivalent multi-vendor stacks.
5. The deploy story is clean. wrangler deploy and you”re live. No CI/CD pipeline required for simple apps; can be added when needed.
What Workers + D1 doesn”t do well
1. Complex queries. D1 is SQLite-based; the query planner isn”t Postgres-grade. Complex joins, window functions, materialized views require workarounds.
2. Native Node.js dependencies. Workers runtime is V8 isolates with Web APIs + a Node.js compatibility layer. Most npm packages work; some don”t. Native addons typically don”t.
3. Long-running operations. Workers have CPU time limits (30 seconds typical). Anything compute-heavy needs Queues + scheduled processing or Workers for Platforms.
4. Postgres-specific features. No pgvector, no advanced full-text search, no JSON operators. SQLite has analogs for some but not all.
5. The ecosystem maturity gap. Postgres has 20+ years of tutorials, Stack Overflow answers, expert knowledge. D1 has years.
The “I”ve used Cloudflare for 4 years” thread tips
The r/CloudFlare “8 tips to boost your SaaS” thread (47 upvotes, Aug 22) — published 17 days after this article — captures the long-term-user perspective. The recurring patterns:
- Enable Workers Cache aggressively. Hit rate matters more than compute optimization.
- Use Workers KV for hot config / session data. Faster than D1 for tiny reads.
- Set up usage alerts in the dashboard. Catches anomalies before they become bills.
- Tier your storage. Workers KV for hot, D1 for relational, R2 for blobs. Don”t use one for everything.
- Use the staging environment. Workers makes this trivial; many users skip it and regret.
The cost comparison reality
The r/nextjs “Cost comparision of hosting Next.js app (after becoming little famous)” thread (212 upvotes, June 26) is the canonical “Vercel got expensive at scale” reference. OP saw their Vercel bill spike from $20 to $200+ as their app scaled. The cross-platform comparison in the thread:
- Vercel (the OP”s prior platform): $200-500/mo at the scale they hit
- Cloudflare Workers + D1: estimated $20-80/mo for equivalent traffic
- Self-hosted Coolify on Hetzner: ~$10-30/mo (more ops work)
- Render: $30-150/mo (middle ground)
The Cloudflare math wins at moderate-traffic SaaS scale. It doesn”t win for very-low-traffic (Vercel free tier covers more), and may not win at very-high-traffic (depends on workload shape).
The r/nextjs “Next.js tech stack that can deploy on any platform” thread (56 upvotes, July 24) reinforces the broader pattern: engineers in mid-2025 increasingly value platform portability, partly as defensive hedge against Vercel-style pricing changes.
The “Unexpected Cloudflare bill” cautionary thread
The r/CloudFlare “Unexpected Cloudflare bill” thread (56 upvotes, June 16) is the cautionary parallel to the Vercel bill-shock stories. Cloudflare also has gotchas. Specifically:
- Workers CPU time charges if you go over free tier limits
- R2 egress charges (technically free for first 10GB; can spike with hotlink abuse)
- D1 row read charges for high-traffic apps
- KV operation charges for chatty apps
The Cloudflare pricing is predictable but not free. Set usage alerts; understand your specific workload”s billing exposure.
The Theo “switched to Postgres” counter-narrative
Theo”s July 4 video — “I finally switched to Postgres” — captures the counter-position. For engineers who prioritize Postgres expertise and the broader Postgres ecosystem, D1 is a downgrade regardless of cost. Real concern; not wrong; depends on what you optimize for.
Theo”s “Vercel Finally Caught Up” (June 27) frames the broader competitive landscape. By mid-2025 the platform race has multiple credible options, and the “always default to Vercel” pattern is no longer the safe choice it was in 2023.
Real-world architecture patterns that work
Three patterns from production:
1. Content site with dynamic features. Workers Static Assets for the bulk content + Workers for the API + D1 for user accounts / comments / interactions. This site (TopInsight) uses a simpler version.
2. SaaS app with global users. Workers compute everywhere + D1 with multi-region replicas + R2 for user-uploaded files. Multi-region by default at the storage layer.
3. Internal tools / dashboards. Workers Static Assets for the frontend + Workers for queries + D1 for application state. Cheap, fast, easy to deploy.
What”s genuinely hard
Patterns that bite:
Schema migrations. D1 migrations work but aren”t as mature as Prisma + Postgres or Drizzle + Postgres. Plan migration timing carefully; test in staging.
Read-after-write consistency. D1 read replicas are eventually consistent. Apps that read what they just wrote need to opt into primary reads via the session API.
Local development. wrangler dev works but has gotchas. Some Workers APIs behave differently locally vs deployed. Test in staging more than you”d expect.
Migrating off D1 later. Vendor lock-in is real. SQLite-flavored schemas don”t cleanly port. If you anticipate needing to leave Cloudflare, factor that into the decision.
Creator POV vs Reddit dissent
The creator landscape through 2025 is increasingly positive on Cloudflare Workers. Lempa, Theo (despite his Postgres consolidation), Fireship — all cover Workers as a serious option.
The Reddit dissent splits productively:
The pro-Cloudflare camp — vocal in r/CloudFlare, growing in r/nextjs. Values: cost, performance, platform integration.
The “Postgres is non-negotiable” camp — accurate for teams that depend on Postgres-specific features. D1 / SQLite is the wrong tool for them.
The “self-host instead” camp — for cost-sensitive users with operational capacity. Coolify on Hetzner is the cheap path; Workers is the “almost as cheap, much less work” path.
The “Vercel still wins on DX” camp — accurate for some workflows. Vercel”s deploy preview UX, integration ecosystem, monitoring tooling are still ahead of Cloudflare in specific dimensions.
What this means for working engineers in early August 2025
Three practical positions:
1. If you”re starting a new SaaS in mid-2025 and don”t need Postgres-specific features, evaluate Workers + D1 seriously. The cost math is meaningfully better than Vercel-equivalent at moderate scale.
2. If you”re Vercel-fatigued or pricing-anxious, the migration cost is real but manageable. Plan a quarter; don”t do it reactively.
3. Set usage alerts on day one. Both Vercel and Cloudflare have bill-shock potential; the alert is the cheap insurance.
The honest critique
What this guide doesn”t address:
- Cloudflare reliability matters. The June 12 outage and July 14 1.1.1.1 incident showed the platform has occasional bad days. Multi-region patterns help; don”t expect zero downtime.
- D1 isn”t Postgres. Worth saying again. The capabilities differ; some workloads fundamentally don”t fit.
- Workers ecosystem is still smaller than Node ecosystem. Some packages don”t work; some need wrappers. Verify your specific dependencies.
- The lock-in risk is real. Worth factoring into long-term plans.
For most working engineers reading this in early August 2025: Workers + D1 is now a credible default for new SaaS builds. Not the universal answer; not the wrong answer either. The economics and ergonomics have crossed the “worth evaluating seriously” threshold for the use cases it fits.
For broader platform context, see our D1 read replicas analysis, Vercel runtime shifts piece, and Cloudflare Workers vs Vercel Edge comparison.
Sources
Every reference behind this piece. If we make a claim, it's because at least one of these said so — or we lived it ourselves.
- YouTube Christian Lempa — "Publish a Static Hugo Website the EASY way // Cloudflare Workers" — Christian Lempa
- YouTube Theo (t3dotgg) — "Vercel Finally Caught Up" (platform context) — Theo / t3dotgg
- YouTube Theo (t3dotgg) — "I finally switched to Postgres." (counter-narrative) — Theo / t3dotgg
- Docs Cloudflare Workers documentation — Cloudflare
- Docs Cloudflare D1 documentation — Cloudflare
- Blog r/CloudFlare — "I've used Cloudflare for 4 years and deployed my SaaS entirely on it. 8 tips" (47 upvotes) — r/CloudFlare
- Blog r/nextjs — "drop your Vercel hosting replacements" (285 upvotes) — r/nextjs
- Blog r/nextjs — "Vercel Edge vs Cloudflare Workers: Vercel CPU 3x slower in my benchmark" (69 upvotes) — r/nextjs
- Blog r/nextjs — "Cost comparision of hosting Next.js app (after becoming little famous)" (212 upvotes) — r/nextjs
- Blog r/CloudFlare — "Unexpected Cloudflare bill" cautionary thread (56 upvotes) — r/CloudFlare
- Blog r/nextjs — "Next.js tech stack that can deploy on any platform like lambda or workers" (56 upvotes) — r/nextjs
- Firsthand Shipped two production SaaS apps on Workers + D1 through 2024-2025