Next.js SaaS Starter
Next.js 16 + GitHub login + Stripe subscriptions + plan gating + transactional email + Postgres/Drizzle.
No auth library to configure, no billing SDK to learn: the whole backend is plain TypeScript in src/lib, readable and
yours to change, installed with GenPM and pinned to verified commits.

What's included
| Feature | Where | How |
|---|---|---|
| GitHub login (Google optional) | src/lib/auth |
Cookie sessions with rotation, OAuth via arctic. Routes in src/app/auth. |
| Stripe subscriptions | src/lib/billing, src/lib/stripe |
Checkout, customer portal, idempotent webhooks mirrored into Postgres. |
| Plan gating | src/lib/billing/plans.ts |
await hasEntitlement(user, 'pro') anywhere on the server. |
| Welcome email | src/lib/email |
React Email templates sent with Resend on first login (console in development). |
| Postgres + Drizzle | src/lib/db |
One client, a schema.ts per module, migrations in drizzle/. |
| Rules for your AI agent | src/lib/*/AGENTS.md |
Claude Code, Cursor, Copilot and Codex know how each module works before changing it. |
Quick start
npx degit GenPM-net/saas-starter my-saas && cd my-saas # or "Use this template" on GitHub
npm install
cp .env.example .env.local # fill it in (see below)
node --env-file=.env.local node_modules/drizzle-kit/bin.cjs migrate --config src/lib/db/drizzle.config.ts
npm run dev
Open http://localhost:3000, sign in with GitHub, then upgrade with Stripe's test card 4242 4242 4242 4242.
Locally, forward Stripe events: stripe listen --forward-to localhost:3000/api/stripe/webhook.
Environment variables
| Variable | What |
|---|---|
DATABASE_URL |
Any Postgres: local, Neon, Supabase, RDS. |
AUTH_SECRET |
32+ random chars: openssl rand -base64 32. |
GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET |
A GitHub OAuth app with callback <APP_URL>/auth/callback/github. |
STRIPE_SECRET_KEY, STRIPE_WEBHOOK_SECRET |
Test-mode keys. Webhook endpoint <APP_URL>/api/stripe/webhook with checkout.session.completed and customer.subscription.created/updated/deleted. |
STRIPE_PRICE_PRO |
The price_… id of your monthly Pro price. |
APP_URL |
Public URL of the app (used in emails). |
RESEND_API_KEY, EMAIL_FROM |
Optional in development (emails are printed). Required in production. |
Add more modules
Need roles and permissions, file uploads, background jobs, a blog or a whole store?
curl -fsSL https://genpm.net/install.sh | sh # or: npx @genpm-net/cli <command>
genpm search roles
genpm add @core/rbac @core/storage @core/jobs
Or ask your agent: run genpm mcp setup once, then "add role-based access control with genpm". Every install shows a
dry-run plan first, never runs install scripts, and lands as source code you own. genpm outdated and genpm update
bring module updates in with a three-way merge that keeps your edits. Browse the catalog at genpm.net.
How this template was made
npx create-next-app@latest saas-starter --ts --app --src-dir --tailwind --eslint
genpm add @core/billing @core/email --install-deps # pulls @core/auth, @core/db and @core/stripe
Then the integration steps from each module's AGENTS.md: route handlers in src/app, the price → feature map in
plans.ts, allowImportingTsExtensions in tsconfig.json, and the landing and account pages. genpm.lock records
the exact commit of every module.
License
MIT. The modules in src/lib are MIT as well (see each LICENSE).
