Skip to main content
← All products
Boilerplatesv1.0.0

Next.js SaaS Boilerplate

Start a SaaS on Next.js with auth, database, emails, admin and billing hooks wired.

Next.js SaaS Boilerplate

Who it's for

  • You are starting a SaaS or an internal tool on Next.js and don't want to spend the first two weeks on sign-up, password reset, emails and an admin page.
  • You want a codebase you can read end to end: no hosted auth service, no paid dependencies to run it locally.
  • You care about tests from day one: unit, integration and end-to-end tests and a CI workflow are already there.

Not for you if you need organisations and teams, SSO/SAML or a payment provider implemented in code out of the box: billing ships as an interface with a mock provider and a step-by-step Stripe guide.

Generated from the zip

What's inside

One Next.js 16 project folder. It runs locally with no accounts and no .env file: the database is a SQLite file, emails go to a local outbox page, and billing uses a mock provider.

  • Routes: 24 routes, including the landing, pricing and legal pages, sign-in and sign-up with email verification and password reset, a dashboard, a Pro-only page, settings, billing, an admin area with users and an audit log, and the API handlers for auth, billing and health.
  • Modules: validated environment, Better Auth configuration, role and plan guards, the Drizzle schema with migrations and a seed, email sending, the billing interface with a mock provider and webhook handling, the audit log and rate limiting.
  • Components and emails: 37 UI components and 4 email templates.
  • Tests and CI: Vitest unit and integration tests on temporary SQLite databases, 3 Playwright end-to-end specs and a GitHub Actions workflow.
  • Guides: getting started, configuration, auth, database, emails, billing (with a Stripe implementation), admin, deployment (Vercel, Netlify, Docker), security and testing.
App routes (pages and API)
24
Files
  • app/(app)/billing/mock-checkout/page.tsx
  • app/(app)/billing/page.tsx
  • app/(app)/dashboard/page.tsx
  • app/(app)/dashboard/reports/page.tsx
  • app/(app)/settings/page.tsx
  • app/(app)/settings/security/page.tsx
  • app/(auth)/forgot-password/page.tsx
  • app/(auth)/reset-password/page.tsx
  • app/(auth)/sign-in/page.tsx
  • app/(auth)/sign-up/page.tsx
  • app/(auth)/verify-email/page.tsx
  • app/(marketing)/page.tsx
  • app/(marketing)/pricing/page.tsx
  • app/(marketing)/privacy/page.tsx
  • app/(marketing)/terms/page.tsx
  • app/admin/audit/page.tsx
  • app/admin/page.tsx
  • app/admin/users/[id]/page.tsx
  • app/admin/users/page.tsx
  • app/api/auth/[...all]/route.ts
  • app/api/billing/checkout/route.ts
  • app/api/billing/webhook/route.ts
  • app/api/health/route.ts
  • app/dev/outbox/page.tsx
Library modules
24
Files
  • lib/audit.ts
  • lib/auth-client.ts
  • lib/auth.ts
  • lib/authz.ts
  • lib/billing/index.ts
  • lib/billing/mock.ts
  • lib/billing/plans.ts
  • lib/billing/service.ts
  • lib/billing/types.ts
  • lib/billing/webhook.ts
  • lib/config.ts
  • lib/db/index.ts
  • lib/db/migrate.ts
  • lib/db/schema.ts
  • lib/db/seed.ts
  • lib/email/index.ts
  • lib/email/messages.ts
  • lib/email/outbox.ts
  • lib/env-files.ts
  • lib/env.ts
  • lib/http.ts
  • lib/rate-limit.ts
  • lib/session.ts
  • lib/utils.ts
UI components
37
Files
  • components/admin/audit-table.tsx
  • components/admin/role-form.tsx
  • components/admin/stat-card.tsx
  • components/admin/users-table.tsx
  • components/auth/auth-card.tsx
  • components/auth/forgot-password-form.tsx
  • components/auth/form-error.tsx
  • components/auth/github-button.tsx
  • components/auth/resend-verification.tsx
  • components/auth/reset-password-form.tsx
  • components/auth/sign-in-form.tsx
  • components/auth/sign-up-form.tsx
  • components/billing/plan-card.tsx
  • components/billing/submit-button.tsx
  • components/billing/upgrade-button.tsx
  • components/marketing/legal-page.tsx
  • components/nav/app-nav.tsx
  • components/nav/app-shell.tsx
  • components/nav/logo.tsx
  • components/nav/site-footer.tsx
  • components/nav/site-header.tsx
  • components/nav/user-menu.tsx
  • components/settings/change-password-form.tsx
  • components/settings/delete-account.tsx
  • components/settings/profile-form.tsx
  • components/settings/sessions-list.tsx
  • components/ui/alert.tsx
  • components/ui/badge.tsx
  • components/ui/button.tsx
  • components/ui/card.tsx
  • components/ui/dialog.tsx
  • components/ui/field.tsx
  • components/ui/input.tsx
  • components/ui/label.tsx
  • components/ui/select.tsx
  • components/ui/table.tsx
  • components/ui/toast.tsx
Email templates
4
Files
  • emails/billing-receipt.tsx
  • emails/reset-password.tsx
  • emails/verify-email.tsx
  • emails/welcome.tsx
Unit and integration tests
15
Files
  • tests/audit.test.ts
  • tests/auth-flow.test.ts
  • tests/authz.test.ts
  • tests/billing-mock.test.ts
  • tests/client-bundle.test.ts
  • tests/db-integration.test.ts
  • tests/emails-render.test.ts
  • tests/env.test.ts
  • tests/guards.test.ts
  • tests/http.test.ts
  • tests/outbox.test.ts
  • tests/plans.test.ts
  • tests/rate-limit.test.ts
  • tests/security-headers.test.ts
  • tests/webhook-idempotency.test.ts
Playwright end-to-end tests
3
Files
  • e2e/admin.spec.ts
  • e2e/auth.spec.ts
  • e2e/billing.spec.ts
Guides
10
Files
  • docs/admin.md
  • docs/auth.md
  • docs/billing.md
  • docs/configuration.md
  • docs/database.md
  • docs/deployment.md
  • docs/emails.md
  • docs/getting-started.md
  • docs/security.md
  • docs/testing.md

In the zip · 161 files · 242 KB

  • .dockerignore
  • .env.example
  • .github/1 files
  • .gitignore
  • AGENTS.md
  • CHANGELOG.md
  • CLAUDE.md
  • Dockerfile
  • LICENSE.md
  • README.md
  • app/35 files
  • components/37 files
  • docs/10 files
  • drizzle.config.ts
  • drizzle/3 files
  • e2e/4 files
  • emails/5 files
  • eslint.config.mjs
  • instrumentation.ts
  • lib/24 files
  • next.config.ts
  • package-lock.json
  • package.json
  • playwright.config.ts
  • postcss.config.mjs
  • proxy.ts
  • public/1 files
  • scripts/4 files
  • tests/17 files
  • tsconfig.json
  • vitest.config.ts

Setup

Requirements

  • Node.js 22.12 or newer and npm
  • Nothing else for local development (SQLite file database, emails written to a local outbox, mock billing provider)
  • For production: a Turso (or other libSQL) database, a Resend account with a verified sending domain, and a host such as Vercel, Netlify or Docker
  • For real payments: a Stripe, Lemon Squeezy or Paddle account (the billing provider is an interface you implement; a guide covers Stripe)
  • For the end-to-end tests: Playwright's Chromium, downloaded once with npx playwright install chromium
  1. Unzip, then install: cd nextjs-saas-boilerplate && npm ci.
  2. Start the app with npm run dev. The first run creates and migrates data/dev.db.
  3. Open http://localhost:3000, choose Create an account and sign up with any email address.
  4. Open http://localhost:3000/dev/outbox and click the verification link. You land on your dashboard.
  5. Optional: npm run db:seed adds an admin and two example users so you can see /admin and the audit log.

Time to first result: about 3 minutes.

Tested with

Clean-install test passed on 2026-10-01 (darwin-arm64, node 22.23.2, npm 10.9.8): extract, base, node, yaml, docs, acceptance.

Licence

You may use this product in unlimited personal and commercial projects, including client work. You may not resell, redistribute, sublicense or share the product itself, in whole or in part, including as a template, starter kit or course material. One purchase covers one person.

The full licence is in LICENSE.md inside the zip. Site terms: /terms.

FAQ

Questions

Do I need Turso or Resend to try it?

No. Locally it uses a SQLite file and writes emails to a dev outbox. For production you add a Turso (or other libSQL) database and a Resend account with a verified sending domain.

How do I take real payments?

Billing is an interface (BillingProvider) with a mock provider and a simulated checkout. You implement it for Stripe, Lemon Squeezy or Paddle; the billing guide walks through Stripe with the provider code.

Has it been deployed to production?

The clean-install test ran lint, type checks, the test suite and a production build on a fresh copy of the zip, and the Playwright suite ran from the same copy. A deployment to Vercel or Netlify with Turso and Resend was not part of those runs; the deployment guide covers the steps.

How do updates work?

New versions go to your Gumroad library; download them from there. Changes are listed in the CHANGELOG inside the zip.

Can I use it for client work?

Yes. Apps you build from it, for yourself or for clients, are yours. You can't resell or share the boilerplate itself.

What about refunds?

Payment goes through Gumroad. All sales are final: the files are delivered instantly, so there are no refunds. Updates within version 1.x are free.

More Boilerplates