Next Starter Logo

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:

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 install

2. Configure environment

Copy the example file to create your local .env.

cp .env.example .env

The 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 secret

Paste 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.

ServiceWhat it powersGuide
Google OAuthSocial sign-inAuthentication
StripeSubscription billingBilling
SMTP2GoTransactional emailEmail
Cloudflare R2File uploads and avatarsFile Uploads
Cloudflare TurnstileBot protection on the contact formTurnstile

3. Start the database

This starts PostgreSQL 18 in Docker, listening on port 5432.

docker-compose up -d

It 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 dev

It 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 dev

5. Start the dev server

This runs Next.js at http://localhost:3000.

pnpm dev

Open 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 email

Edit any file in lib/email/ and the preview reloads right away.

What you should see

RoutePage
/Marketing landing page
/auth/registerRegistration
/auth/sign-inSign in
/dashboardUser 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

On this page