This is a template for Next.js app router + Mantine. If you want to use pages router instead, see next-pages-template.
This template comes with the following features:
- PostCSS with mantine-postcss-preset
- TypeScript
- Storybook
- Jest setup with React Testing Library
- ESLint setup with eslint-config-mantine
- Prisma ORM with PostgreSQL
- Docker setup for local development
-
Install dependencies
pnpm install
-
Set up environment variables
cp .env.example .env
Or create
.envfile with:DATABASE_URL="postgresql://postgres:postgres@localhost:5433/nextapp?schema=public" -
Start the database
pnpm run db:up
-
Set up Prisma
pnpm run db:generate pnpm run db:migrate
-
Seed the database (optional)
pnpm run db:seed
-
Start the development server
pnpm dev
dev– start dev serverbuild– bundle application for productionstart– start production serveranalyze– analyzes application bundle with @next/bundle-analyzer
db:up– start PostgreSQL containerdb:down– stop all Docker containersdb:reset– reset database (removes all data and restarts container)db:migrate– run database migrationsdb:generate– generate Prisma clientdb:studio– open Prisma Studio (database GUI at http://localhost:5555)db:seed– seed database with initial datadb:push– push schema changes to database (development only)
typecheck– checks TypeScript typeslint– runs ESLint and Stylelinteslint– runs ESLint onlystylelint– runs Stylelint onlyprettier:check– checks files with Prettierjest– runs jest testsjest:watch– starts jest watchtest– runsjest,prettier:check,lintandtypecheckscripts
storybook– starts storybook dev serverstorybook:build– build production storybook bundle tostorybook-staticprettier:write– formats all files with Prettier
This project uses PostgreSQL with Prisma ORM. The database runs in a Docker container for easy development.
The project includes the following Prisma models:
- User: User accounts with email, name, and timestamps
- Post: Blog posts with title, content, author relationship, and publish status
- PostgreSQL:
localhost:5433 - Username:
postgres - Password:
postgres - Database:
nextapp - Prisma Studio: Available at
http://localhost:5555after runningpnpm run db:studio
import { prisma } from '@/lib/prisma';
// Get all users
const users = await prisma.user.findMany();
// Create a new user
const user = await prisma.user.create({
data: {
email: 'user@example.com',
name: 'John Doe',
},
});
// Get user with posts
const userWithPosts = await prisma.user.findUnique({
where: { id: 'user-id' },
include: { posts: true },
});
// Create a new post
const post = await prisma.post.create({
data: {
title: 'New Post',
content: 'Post content here...',
authorId: 'user-id',
published: true,
},
});When you modify the Prisma schema:
- Edit
prisma/schema.prisma - Create and apply migration:
pnpm run db:migrate - Generate updated client:
pnpm run db:generate
For development-only changes, you can use: pnpm run db:push
The project uses Docker Compose to manage the PostgreSQL database:
# Start database (detached mode)
pnpm run db:up
# View logs
docker-compose logs postgres
# Stop containers
pnpm run db:down
# Reset database (removes all data)
pnpm run db:reset
# Connect to database directly
docker exec -it next-app-postgres psql -U postgres -d nextapp├── app/ # Next.js app directory
│ ├── api/ # API routes
│ ├── users/ # User pages
│ ├── layout.tsx # Root layout
│ └── page.tsx # Home page
├── components/ # Reusable components
├── lib/ # Utility libraries
│ └── prisma.ts # Prisma client instance
├── prisma/ # Database schema and migrations
│ ├── schema.prisma # Database schema
│ ├── migrations/ # Database migrations
│ └── seed.ts # Database seed file
├── docker/ # Docker configuration
└── docs/ # Documentation
- Port 5433 already in use: Stop existing PostgreSQL service or change port in
docker-compose.yml - Connection errors: Ensure Docker container is running with
pnpm run db:up - Migration errors: Try
pnpm run db:resetto start fresh - Prisma Client errors: Run
pnpm run db:generateto regenerate the client
For detailed database setup instructions, see docs/DATABASE_SETUP.md.