Get Started
Set up Next Starter locally: clone the repo, set environment variables, start PostgreSQL in Docker, run Prisma migrations, and start the Next.js dev server.
Follow the steps below to get a local copy running.
Prerequisites
Install these first:
- Node.js 20+. Next.js 16 requires it.
- pnpm. The package manager this template uses.
- Docker. Runs PostgreSQL on your machine through
docker-compose. - Google OAuth credentials. Optional, only for social sign-in.
1. Clone and install
This downloads your copy of the template and installs its dependencies.
git clone <your-repo-url> my-app
cd my-app
pnpm install2. Configure environment
Copy the example file to create your local .env.
cp .env.example .envThe defaults in .env.example already work for local development. The database URL, app URLs, and PostgreSQL credentials all match docker-compose.yml. You only need one thing to start: an auth secret.
Generate it:
pnpm dlx auth secretPaste the output into BETTER_AUTH_SECRET in .env.
Every other service is optional for the first run. Each one has its own guide below. For the full list of variables (validated with Zod when the app starts), see the Environment Variables reference.
| Service | What it powers | Guide |
|---|---|---|
| Google OAuth | Social sign-in | Authentication |
| Stripe | Subscription billing | Billing |
| SMTP2Go | Transactional email | |
| Cloudflare R2 | File uploads and avatars | File Uploads |
| Cloudflare Turnstile | Bot protection on the contact form | Turnstile |
3. Start the database
This starts PostgreSQL 18 in Docker, listening on port 5432.
docker-compose up -dIt creates a next_starter database with the postgres / postgres credentials that the default DATABASE_URL expects.
4. Run migrations
This creates your database tables and generates the Prisma client.
pnpm prisma migrate devIt adds the user, session, account, verification, and subscription tables.
To wipe the database and start fresh, run:
docker-compose down -v && docker-compose up -d && pnpm prisma migrate dev5. Start the dev server
This runs Next.js at http://localhost:3000.
pnpm devOpen the URL in your browser.
Production builds run migrations for you
pnpm dev only starts Next.js. The build script runs prisma generate && next build && prisma migrate deploy. So a production deploy applies any pending migrations on its own. You never run them by hand in production.
Preview email templates (optional)
This opens the React Email preview at http://localhost:3001.
pnpm emailEdit any file in lib/email/ and the preview reloads right away.
What you should see
| Route | Page |
|---|---|
/ | Marketing landing page |
/auth/register | Registration |
/auth/sign-in | Sign in |
/dashboard | User dashboard (requires sign in) |
Create an account at /auth/register. To make yourself an admin, open the user table and set the role field on your row to "admin".
Next steps
- Read the overview to see what each module does
- Set up Stripe to turn on subscription billing
- Skim the project structure to find where things live
Introduction
Next Starter is a Next.js 16 SaaS boilerplate with Better Auth, Stripe billing, Prisma and PostgreSQL, file storage, email, and an admin dashboard.
Project Structure
A map of the Next Starter directory layout: every folder and file in this Next.js SaaS kit, plus conventions for where new pages, components, and actions go.