Local Development
Learn how to set up your local development environment.
This guide will help you set up your local development environment for the Pro Next.js Prisma starter kit, including the necessary services like PostgreSQL.
Prerequisites
To run the application locally, you need to have the following:
- Node.js 22.21.1, matching the version in
package.json - npm (comes with Node.js)
- PostgreSQL (v14 or later)
Recommended Startup Order
Start only the services needed for the flow you are testing:
| Order | Service | Command | Local address | Required |
|---|---|---|---|---|
| 1 | PostgreSQL 17 | npm run docker:up | localhost:5432 | Yes |
| 2 | Next.js | npm run dev | http://localhost:3000 | Yes |
| 3 | React Email preview | npm run email:dev | http://localhost:3001 | Only when editing email templates |
| 4 | Stripe webhook forwarding | npm run stripe:listen | Forwards to /api/webhooks/stripe | Only when testing billing events |
The Stripe command requires the Stripe CLI
and an authenticated Stripe account. Copy the temporary whsec_... value it
prints into STRIPE_WEBHOOK_SECRET, then restart Next.js.
Setting Up Local Services
Option 1: Local PostgreSQL Installation
Install PostgreSQL on your machine and create a database:
createdb your_database_nameOption 2: Docker Compose (Recommended)
The repository includes a docker-compose.yml file with PostgreSQL 17. It
creates a database named database with the password password.
Starting the Services
- Start the services using Docker Compose:
npm run docker:up- Verify that the services are running:
docker compose psEnvironment Configuration
Start from the environment template shipped with the repository:
cp .env.example .envThe template already contains the local Docker database URL and
NEXT_PUBLIC_SITE_URL. Replace its example BETTER_AUTH_SECRET with a unique
value before starting the application:
Generate a Better Auth secret
Generated locally with your browser's cryptographic random number generator. The value is never sent to Achromatic.
Add it to Paste the copied line into your local .env file and use a separately generated value in production.
Optional integrations may remain empty until you test them. Password signup
does require RESEND_API_KEY and EMAIL_FROM because new accounts must verify
their email. Use the environment variables
guide to
select complete variable groups for email, Stripe, Google sign-in, AI, storage,
Turnstile and Sentry.
Accessing the Services
- PostgreSQL:
- Host: localhost
- Port: 5432
- Username: postgres
- Password: password
- Database: database
Running Database Migrations
After setting up your database, run the migrations:
npm run db:migrate:devThis command will:
- Create and apply migrations
- Automatically regenerate Prisma Client
Start Development Server
Start the development server:
npm run devYour application should now be running at http://localhost:3000 with the local PostgreSQL database.
Troubleshooting
Database Connection Issues
If you're having trouble connecting to PostgreSQL:
- Verify the database is running:
docker compose ps postgres- Check the logs:
docker compose logs postgres- Verify your
DATABASE_URLin.envmatches your database configuration
Port Already in Use
If port 3000 is already in use, you can change it by setting the PORT environment variable:
PORT=3002 npm run devPort 3001 is reserved by the included React Email preview command. If you
change the application port, also update NEXT_PUBLIC_SITE_URL, OAuth callback
URLs and the target used by Stripe webhook forwarding.
Stopping the Services
To stop all services:
npm run docker:downTo stop and remove all data (including volumes):
docker compose down -v