README > NextJS Deploy > Setup Local
- Bun
- OrbStack (macOS) or Docker (Linux)
- Make
- PostgreSQL — provides
psqlandpg_dumpforscripts/db.shandmake dump
On macOS:
brew install postgresql@17
curl -fsSL https://bun.sh/install | bash
brew install --cask orbstack # Docker Desktop alternative for macOSOn Linux (Ubuntu/Debian):
# Node.js via NodeSource
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt install -y nodejs make postgresql-client
# Bun
curl -fsSL https://bun.sh/install | bash
# Docker
sudo apt install -y docker.io docker-compose-plugin
sudo usermod -aG docker $USERBest option for daily work. Next.js runs locally (fast hot-reload), Postgres in Docker.
make devFirst run: if env/env.config.mjs doesn't exist, the command creates it and stops. Configure your variables in the generated file, then re-run make dev. See Environment Variables for details.
Further runs: installs deps, generates .env files, starts Postgres, sets up DB, loads fixtures and starts Next.js.
Stop with Ctrl+C — shuts down both Next.js and Postgres.
Same as make dev but builds and serves the production bundle. Use to verify everything works before deploying.
make startStop with Ctrl+C — shuts down both Next.js and Postgres.
Builds the Next.js Docker image with database access (for generateStaticParams), then runs it. Postgres runs separately via compose.postgres.yml — the build accesses it through the host network.
make dockermake docker-stop # Stop Next.js container + Postgres
make docker-clear # Stop all + delete volumesKeep Postgres running independently and restart Next.js freely without the overhead of make dev / make start (no reinstall, no DB reset, no fixtures reload). Ideal when you need to run bun run dev or bun run build frequently.
make postgres # Start Postgres only (port 5433)Then start Next.js in another terminal, with one of the following commands:
# Dev mode
bun run dev # Start Next.js dev server
bun run auto # Install deps, setup DB, load fixtures and start Next.js
# Build mode
bun run build && bun run start # Test production build
bun run auto:start # Install deps, setup DB, load fixtures and start production buildCtrl+C only stops Next.js — Postgres keeps running. Stop it when done:
make postgres-stop # Stop container
make postgres-clear # Stop + delete volumeExpose localhost:3000 through a public URL. Useful for mobile testing or sharing.
-
Create an account at ngrok.com
-
Setup your authtoken from the dashboard
-
Get a free static domain at Domains
-
Set your static domain in
env/env.config.mjsin thetunnellingsection. See Environment Variables for details.tunnelling: { NGROK_URL: commented("your-static-domain.ngrok-free.app"), // Change here NEXT_PUBLIC_BASE_URL: commented(template("https://{{NGROK_URL}}")), // Do not change this one },
-
Run
make setup-envto regenerate env files -
In the generated
.envat root, commentNEXT_PUBLIC_BASE_URL=http://localhost:3000and uncomment the ngrok block:# Next.js configuration NEXTJS_STANDALONE=false # NEXT_PUBLIC_BASE_URL=http://localhost:3000 // Comment this line ... # Ngrok tunnelling (optional) NGROK_URL=your-static-domain.ngrok-free.app // Uncomment this line NEXT_PUBLIC_BASE_URL=https://your-static-domain.ngrok-free.app // Uncomment this line
-
Start in two terminals:
# Terminal 1 make dev # Terminal 2 make ngrok
Export the database schema to prisma/dump.sql. Requires an active Postgres container (make dev or make postgres).
make dumpRemove all generated files and folders:
make clearDeletes: .husky/_, .next, node_modules, prisma/client, next-env.d.ts, tsconfig.tsbuildinfo, .env, env/.env.docker, env/.env.experiment, env/.env.preview, env/.env.production.
README > NextJS Deploy > Setup Local