cloudflare-saas-stack: Next.js on Pages with D1, Drizzle and a bun setup script
Quickly make and deploy full-stack apps with database, auth, styling, storage etc. figured out for you. Add all primitives you want.
At a glance
- What is it?
- A TypeScript starter that wires Next.js, NextAuth, Drizzle and Cloudflare D1 together for deployment to Cloudflare Pages, with two migration paths and a few setup gaps to know about before you clone it.
- Who is it for?
- Use this kit if you already have a Cloudflare account, are comfortable with bun, and want Google sign-in plus a D1 database running on Pages in one sitting. Skip it if you need a declared license, a tagged release to pin, or a stack that is not Next.js 14 with a beta NextAuth.
- Can I use it commercially?
- The repository metadata does not identify a licence. Check the project’s published terms and any component-specific licences before reuse.
- Is it still maintained?
- Yes. The repository last received commits 54 days ago.
- What is it written in?
- Mainly TypeScript, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 25, 2026, and from our analysis. They are not legal advice.
Star history
- supermemoryai/cloudflare-saas-stack3,757 ★ · +5
| Repository | 2026-11-03 | 2026-11-25 |
|---|---|---|
| supermemoryai/cloudflare-saas-stack | 3.8k | 3.8k |
5 Stars in the last 22 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
Four commands and a setup script stand between clone and a running app
The getting-started path assumes Wrangler is installed and that you have already run wrangler login against a Cloudflare account. After that, the clone-and-install block is short:
git clone https://github.com/Dhravya/cloudflare-saas-stack
cd cloudflare-saas-stack
npm i -g bun
bun install
bun run setupThe install step uses bun, and the project installs bun globally through npm first. The last command points at scripts/setup.ts, which package.json maps to the setup script. Its dependencies include @clack/prompts and @iarna/toml, which suggests an interactive prompt that edits TOML, and the repository root does contain a wrangler.toml. The project does not describe what the script asks or changes, so read scripts/setup.ts before running it against an account that already holds data.
Note that the clone URL points to Dhravya/cloudflare-saas-stack, while the repository being described lives under supermemoryai. Both names appear in the project, so check which one you cloned when you compare commits.
After setup, bun run dev starts the Next.js server, and http://localhost:3000 is where the project says to look.
Seven named pieces make up the stack, and Pages is the only host
The stack list is explicit: Next.js for the frontend, TailwindCSS for styling, Drizzle ORM for database access, NextAuth for authentication, Cloudflare D1 for serverless databases, Cloudflare Pages for hosting, and ShadcnUI as the component library. Nothing else is promised. There is no payment provider, no email sender and no admin panel in that list, so a SaaS built on it still has to bring billing and mail from elsewhere.
package.json pins the versions that matter. Next is 14.2.5, react is ^18, drizzle-orm is ^0.33.0, drizzle-kit is ^0.24.2, and next-auth is ^5.0.0-beta.20, a beta release range. wrangler is ^3.74.0 and @cloudflare/next-on-pages is set to 1. The project is marked private at version 0.1.0.
The devDependencies also contain vercel at ^37.3.0, although the only deployment target the project describes is Cloudflare Pages. The project does not say why vercel is there. Hosting is therefore decided for you: the deploy script runs bun pages:build and then wrangler pages deploy, and there is no Dockerfile among the top-level entries.
The top level also holds components.json for ShadcnUI, tailwind.config.ts, postcss.config.mjs, next.config.mjs, tsconfig.json and a bun.lockb lockfile. A .cursorrules file is present too, so editors that read it will pick up the project's own instructions. The repository lists no license in its metadata, which matters if you plan to fork it for a commercial product: ask the owner before you build on it. The last push was on 2026-10-02, and GitHub shows no releases, so you track main directly.
The c3 scripts add pages:build, preview, deploy and cf-typegen
The project was bootstrapped with c3, Cloudflare's create tool, and c3 added four scripts next to dev. In package.json they read as follows: pages:build runs bunx @cloudflare/next-on-pages, preview runs bun pages:build and then wrangler pages dev, deploy runs bun pages:build and then wrangler pages deploy, and cf-typegen runs wrangler types with the env interface CloudflareEnv written to env.d.ts.
The repository root includes both cf-env.d.ts and env.d.ts, which fits that typegen output, though the project does not explain the split.
The warning that matters here is about dev mode. The note in the project says the dev script is the best option for local work, but you should preview the Pages build periodically to confirm that the app behaves in the Pages environment. next dev and the Pages runtime are different targets. A route that works under bun run dev can fail after bun run preview, so run preview before the first deploy and not after a failed one.
The lint script is next lint, with an .eslintrc.json at the root and eslint-plugin-next-on-pages as a dev dependency.
Local D1 is a SQLite file and production D1 is reached over REST
The database section explains two modes. Locally, Wrangler generates SQLite files at .wrangler/state/v3/d1 after bun run dev, and the dev server talks to a local D1 session built on those files. Inside Pages and Workers you can query D1 directly through the client API exposed by bindings such as env.BINDING, or you can use the REST API.
Drizzle-kit follows the same split. With the dev scripts, drizzle-kit migrate and drizzle-kit studio modify the local SQLite files directly, as regular SQLite databases. With the prod scripts, drizzle-kit uses the d1-http driver to reach the remote D1 database over the REST API. That is why the .env.example file exists, and it holds three empty values:
CLOUDFLARE_D1_ACCOUNT_ID=
DATABASE=
CLOUDFLARE_D1_API_TOKEN=The comment above them says they are variables for running drizzle-kit on your production database with bun run db:migrate:prod. The project does not say what scopes the API token needs, so create it with the minimum D1 permission your account offers and test a migration on an empty database first. Local migrations never need these three values.
The migration command is spelled db:migrate:prd in one place and db:migrate:prod in the rest
Two sets of commands drive the schema. To create migration files, run bun run db:generate, which maps to drizzle-kit generate. To apply them in development, the project lists bun run db:migrate:dev. For production it lists bun run db:migrate:prd in the migration list, but the package.json script is named db:migrate:prod, and the manual setup steps also say bun run db:migrate:prod. A command typed as db:migrate:prd will not match any script in package.json.
Inspection follows the same pattern. bun run db:studio:dev opens Drizzle Studio against the local database, and bun run db:studio:prod opens it against the remote one, with NODE_ENV=production set in the script.
The production scripts set NODE_ENV=production inline, in the form NODE_ENV=production drizzle-kit migrate. On Windows shells that syntax does not work without a helper, and the project mentions none, so Windows users should run these from WSL or a POSIX shell.
The drizzle/ directory sits at the repository root with drizzle.config.ts beside it, and the manual path refers to migrations/0000_setup.sql as the file to execute.
Manual setup needs an OAuth consent screen, two origins and two redirect URIs
The manual route replaces bun run setup. You create a Cloudflare account, install Wrangler, and create a D1 database with bunx wrangler d1 create followed by your database name. Then you write a .dev.vars file in the project root holding AUTH_SECRET, AUTH_GOOGLE_ID and AUTH_GOOGLE_SECRET.
AUTH_SECRET comes from openssl rand -base64 32 or bunx auth secret. The Google values come from the Google Cloud console. You create an OAuth consent screen first, and the project adds a tip that skipping the logo upload avoids a wait. Then you create a credential and enter two Authorized JavaScript origins, https://your-domain and http://localhost:3000, and two Authorized redirect URIs, https://your-domain/api/auth/callback/google and http://localhost:3000/api/auth/callback/google.
Google is the only identity provider the project documents. NextAuth supports others in general, but nothing in this repository describes adding one. If your users do not have Google accounts, plan to write that provider configuration yourself.
The manual steps finish with the local migration, the remote migration, bun run dev and bun run deploy. Each migration can be run through bunx wrangler d1 execute with the --local or --remote flag and the 0000_setup.sql file, or through drizzle.
The R2 bucket needs a CORS policy, and the project gives GET and PUT only
File upload goes through a Cloudflare R2 bucket, and the project warns you not to forget its CORS policy. The policy it gives is this:
[
{
"AllowedOrigins": [
"http://localhost:3000",
"https://your-domain.com"
],
"AllowedMethods": [
"GET",
"PUT"
],
"AllowedHeaders": [
"Content-Type"
],
"ExposeHeaders": [
"ETag"
]
}
]Replace your-domain.com with the real origin. The policy allows GET and PUT, only the Content-Type request header, and exposes ETag, which suggests direct browser uploads to the bucket. A DELETE from the browser, or a multipart upload that sends other headers, would be blocked until you widen the policy.
The project says you can now even set up object upload, and it stops there. It gives no code for creating the bucket or binding it, and R2 does not appear in the stack list. Treat storage as a pointer to what Cloudflare can add, because wiring it is left to you.
The closing claim that no environment variables are needed, with env.DB, env.KV, env.Queue and env.AI as examples, sits beside a manual setup that requires .dev.vars and an .env.example for production migrations. Read it as meaning that bindings replace connection strings.
Editorial conclusion
Use this kit if you already have a Cloudflare account, are comfortable with bun, and want Google sign-in plus a D1 database running on Pages in one sitting. Skip it if you need a declared license, a tagged release to pin, or a stack that is not Next.js 14 with a beta NextAuth. Before building on it, run bun run setup on a throwaway account and confirm that bun run deploy publishes a working login page.
Frequently asked questions
What stack does the cloudflare-saas-stack kit use?
It uses Next.js, TailwindCSS, Drizzle ORM, NextAuth, Cloudflare D1, Cloudflare Pages and ShadcnUI. The project says this is the same stack used to build Supermemory.ai.
What is a SaaS stack in cloudflare-saas-stack?
Here it is an opinionated starter kit for building and deploying SaaS products on Cloudflare, with database, auth, styling and storage chosen for you. You can add more primitives on top.
What does cloudflare-saas-stack do on Cloudflare?
It deploys a Next.js app to Cloudflare Pages with bun run deploy and keeps data in a Cloudflare D1 database. Authentication goes through NextAuth with Google OAuth credentials.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/supermemoryai-cloudflare-saas-stack)Star history chart for your README
[](https://hysenlabs.com/projects/supermemoryai-cloudflare-saas-stack)Was this useful?