Next.js with PostgreSQL – Getting Started
1 views
Next.js with PostgreSQL – Getting Started
This is a Next.js project with a PostgreSQL backend and Prisma.
What you need (local deploy)
- Node.js (v16+)
- Docker & Docker Compose (for PostgreSQL)
- Environment:
DATABASE_URLin.env(see below)
Local deployment (full)
1. Start PostgreSQL (Docker)
docker-compose up -d
Uses: user postgres, password postgres, port 5432, DB postgres.
2. Environment
Copy .env.example to .env (or create .env with):
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/postgres"
3. Install dependencies and DB
npm install
npx prisma generate
npx prisma migrate deploy
4. Optional – seed sample posts
npx prisma db seed
5. Run the app
npm run dev
Open http://localhost:3000.
To stop Postgres: docker-compose down (add -v to remove the data volume).
Getting Started (after deploy)
Run the development server:
npm run dev
# or
yarn dev
Open http://localhost:3000 with your browser.
You can start editing the page by modifying pages/index.tsx. The page auto-updates as you edit.
API routes can be accessed at /api/*. Files in pages/api are treated as API routes.
Learn More
- Next.js Documentation – learn about Next.js features and API.
- Learn Next.js – interactive Next.js tutorial.
- Next.js GitHub repository – feedback and contributions welcome!
Deploy on Vercel
The easiest way to deploy your Next.js app is to use the Vercel Platform. Check out the Next.js deployment documentation for more details.