Cloudflare SaaS Stack
Dhravya/cloudflare-saas-stack ↗ ·★ 2.1k ·TypeScript ·MIT
A Next.js SaaS starter that runs fully on Cloudflare — Pages, Workers, D1 and Drizzle ORM, with Neon as an optional managed Postgres. Built for a $0 starting bill.
Overview
Cloudflare SaaS Stack is a Next.js starter designed around one goal: launch a SaaS without a hosting bill until you actually have users. Every piece runs on Cloudflare — the app deploys to Pages with edge rendering, data lives in D1 (Cloudflare’s SQLite at the edge) accessed through the type-safe Drizzle ORM, and background logic runs on Workers. There is no separate server or container to pay for.
The template makes a deliberate database choice that scales with you. D1 is the default because it is free and colocated with your app, but the stack also wires up Neon’s serverless Postgres for when you need richer relational features or more storage than D1’s free tier provides. Swapping is a configuration change, not a rewrite, so you are not boxed in by the early $0 decision.
What you get out of the box is the unglamorous-but-essential plumbing: routing, a typed data layer, auth and billing wiring, and a deploy configuration that just works with Cloudflare Pages. It is a starting point rather than a finished app — you bring the product, and the stack keeps the infrastructure cheap and consistent.
Highlights
- ✓ Full Next.js app deployed to Cloudflare Pages with edge rendering
- ✓ Type-safe data layer with Drizzle ORM over Cloudflare D1 (SQLite at the edge)
- ✓ Optional Neon serverless Postgres when you outgrow D1
- ✓ Auth, billing wiring and project structure already in place
Best for
- →Indie hackers bootstrapping a SaaS on a $0 budget
- →Teams that want to stay inside the Cloudflare ecosystem
- →Projects that need edge performance without a separate backend
Getting started
- 1 Clone the repo and run npm install
- 2 Run npx wrangler d1 create to provision a D1 database (or set a Neon connection string)
- 3 Copy .dev.vars / configure secrets for auth and database
- 4 Run npm run dev locally, then deploy with the Cloudflare Pages integration
FAQ
Start with D1: it is bundled with Cloudflare, fast at the edge and free for small workloads. Switch to Neon's serverless Postgres when you need relational features or larger storage than D1's free tier offers.
For early-stage usage, yes — Cloudflare Pages, Workers and D1 all have free tiers that cover a low-traffic SaaS. You pay as you scale, which is the point of the stack.
It is a starter, not a finished product. The plumbing (routing, ORM, auth, deploy config) is production-shaped, but you still add your own features and harden it before launch.
Deploy Cloudflare SaaS Stack for free
Free-tier platforms that can host this project. Pick one and ship it.