Build and deploy scalable products on Cloudflare with ease.
An opinionated, batteries-included starter kit for quickly building and deploying SaaS products on Cloudflare.
- Turborepo for monorepo management
- Next.js for frontend
- TailwindCSS for styling
- Drizzle ORM for database access
- NextAuth for authentication
- Cloudflare D1 for serverless databases
- Cloudflare Pages for hosting
- Biome for formatting and linting
- ShadcnUI as the component library
... while still being minimal and composable.
To use, simply clone this repo and run the following commands:
-
Make sure that you have Wrangler installed.
-
Run the following commands:
git clone https://github.com/Dhravya/cloudflare-saas-stack
cd cloudflare-saas-stack
npm i -g bun
bun install
bun run setup
That's it. You're ready to go! Next time, you can just run bun run dev
and start developing.
When you're ready to deploy, run bun run deploy
to deploy to Cloudflare.
An automatic setup script is provided, but you can also manually set up the following:
- Create a Cloudflare account and install the Wrangler CLI.
- Create a D1 database under "Workers and Pages" in the Cloudflare dashboard, or run ``bunx wrangler d1 create ${dbName}`
- Create a
.dev.vars
file inapps/web
with the following content (Get these from google developer console):
GOOGLE_CLIENT_ID=${your-google-client-id}
GOOGLE_CLIENT_SECRET=${your-google-client-secret}
NEXTAUTH_SECRET=${your-secret}
- In
apps/web
, run this command to make migrations to setup auth with database:bunx wrangler d1 execute ${dbName} --local --file=migrations/0000_setup.sql
. This creates a local version of the database and creates the appropriate tables. - Run remote migration for the production database - same command without
--local
:bunx wrangler d1 execute ${dbName} --file=migrations/0000_setup.sql
- Bun
bun run dev
to start the development server. - Run
bun run deploy
to deploy to Cloudflare.