nextjs-template
FeaturesSecurityGitHub
Sign in
Open-source Next.js production template

Ship products,
not boilerplate.

Built for AI coding agents. Auth, database, payments, and more — production-wired so Claude Code can ship features from the first prompt.

Get the templateLive demo
terminal
$ bunx degit your-org/nextjs-template my-app
$ cd my-app && bun install
$ bun run template:init
Project name (kebab-case): my-saas-app
Display name: My SaaS App
Description: The best SaaS ever built
✓ Replaced 42 placeholders across 12 files
$ bun run dev:init
Creating .env.local...
Generated BETTER_AUTH_SECRET
Generated VAPID keys
✓ Ready — run bun run dev to start building
Next.js 16React 19React CompilerTypeScriptTailwind CSS v4BunPostgreSQLDrizzleBetter AuthStripeAI SDKResendDockerBiomeVitestPlaywright

Everything you need.
Nothing you don't.

Every feature is production-tested and designed to work together. No loose wiring, no TODO comments, no “exercise for the reader.”

Authentication

Google OAuth with Better Auth. Admin roles, organizations, auto-provisioning. Protected routes out of the box.

Database

PostgreSQL + Drizzle ORM with typed schema, SQL migrations, shared Docker container, and one-command provisioning.

Row-Level Security

Organization-scoped RLS policies on Postgres. Tenant context set per-request. Fails closed — zero rows on missing context.

Stripe Billing

Subscription scaffold with webhook sync, customer auto-creation, checkout flow, and portal. Degrades gracefully without keys.

AI SDK

Streaming chat with tool use. Anthropic and OpenAI wired as examples — swap in any of 20+ supported providers.

Email

Transactional email with Resend + React Email. Welcome and invitation templates included. Graceful fallback when unconfigured.

PWA + Push

Service worker with offline fallback, install prompt, VAPID push notifications. Works when the app is backgrounded.

Testing

Vitest + Testing Library for unit tests, Playwright for E2E. API contract tests. Docker build fails on any test failure.

One-Command Deploy

Automated Coolify deployment — provisions DB, sets env vars, configures DNS, triggers build. Zero clickops.

Defense-in-depth

8 layers deep.
Fails closed.

Security isn't a feature — it's the foundation. Every request passes through multiple independent checks. If any layer can't verify, access is denied.

01Cloudflare WAF
Origin-locked, rate limiting, TLS
02Security Headers
HSTS, X-Frame-Options, COOP/COEP
03Content Security Policy
Strict policy, Cloudflare-compatible
04Auth Rate Limits
30/min global, 5/hr signup
05Route Guards
Layout-level session + admin checks
06Action Guards
Server-side Zod validation
07Tenant Context
Per-request org scope via set_config
08Row-Level Security
Postgres RLS, fails closed
Zero clickops

Deploy in
one command.

The deploy script provisions your database, sets every env var, configures DNS, and triggers the first build. No clicking through dashboards.

Coolify
Docker
SSL/TLS
Health checks
deploy
$ bun run deploy:coolify
Provisioning database...
✓ Database created
Setting environment variables...
✓ 23 variables configured
Configuring Cloudflare DNS...
✓ DNS records created
Triggering build...
✓ Build queued — deploying
Live at https://my-app.com

Three steps to production.

01

Clone

$ bunx degit your-org/nextjs-template my-app

Get the full template with every feature, pre-wired and tested.

02

Initialize

$ bun run template:init && bun run dev:init

Name your project, generate secrets, configure OAuth. Two minutes.

03

Ship

$ bun run deploy:coolify

One command provisions everything and deploys. You're live.

Stop scaffolding.
Start building.

Auth, database, payments, email, AI, push notifications, testing, deployment — already done. Your first commit is a product feature.

Get the templateView on GitHub
PrivacyTermsGitHub