DEV Community

Nabin Kandel
Nabin Kandel

Posted on

🚀 NestJS + Prisma V7 + Vercel Starter

A minimal, production‑ready REST API with JWT authentication and todo CRUD, built with NestJS, Prisma v7, and PostgreSQL — optimised for Vercel serverless deployment.

Stop wrestling with boilerplate. Clone this, configure your database, and you've got a live API in minutes.


✨ What's included

  • 🔐 JWT auth – register and login endpoints ready to go
  • 📝 Full todo CRUD – each user manages their own private list
  • 🧩 Clean NestJS architecture – separate modules for auth, todo, and a shared prisma service
  • Serverless‑ready – Prisma client singleton prevents connection exhaustion on Vercel
  • 🛠️ Zero‑config deployment – push to GitHub, import to Vercel, done

⚡ Quick Setup

1. Clone and rename

git clone https://github.com/nabinkdl/Nest-setup my-app
cd my-app
Enter fullscreen mode Exit fullscreen mode

Rename my-app to whatever fits your project. Then start fresh:

rm -rf .git && git init
Enter fullscreen mode Exit fullscreen mode

2. Set project metadata (no manual editing)

npm pkg set name="your-name"
npm pkg set description="this is your description"
npm pkg set author="your name"
npm pkg set license="MIT"
Enter fullscreen mode Exit fullscreen mode

3. Install dependencies

bun install        # you can also use npm or yarn
Enter fullscreen mode Exit fullscreen mode

4. Configure your database

cp .env.example .env
Enter fullscreen mode Exit fullscreen mode

Open .env and add your PostgreSQL connection string:

DATABASE_URL="postgresql://user:password@host:5432/mydb?schema=public"
Enter fullscreen mode Exit fullscreen mode
Provider Connection string tip
Neon append ?sslmode=require
Supabase append ?pgbouncer=true
Railway use the provided string as‑is

5. Run the migration

bunx prisma migrate dev --name init
Enter fullscreen mode Exit fullscreen mode

(Optional) Explore your data with Prisma Studio:

bunx prisma studio
Enter fullscreen mode Exit fullscreen mode

6. Start developing

bun run start:dev
Enter fullscreen mode Exit fullscreen mode

Your API is now live at http://localhost:3000 🎉


☁️ Deploy to Vercel

  1. Push your repo to GitHub.
  2. Import the project on vercel.com/new.
  3. Add the environment variables:
    • DATABASE_URL – your PostgreSQL connection string
    • NODE_ENVproduction
  4. Hit Deploy – Vercel will automatically run:
   bunx prisma generate && bun run build
Enter fullscreen mode Exit fullscreen mode

Your serverless NestJS API is now live!


📡 API Endpoints

All /todos routes require a JWT Bearer token in the Authorization header.

Method Route Body (JSON) Description
POST /auth/register {"email": "user@test.com", "password": "123"} Register a new user
POST /auth/login {"email": "user@test.com", "password": "123"} Login, receive a JWT
GET /todos List all user's todos
GET /todos/:id Get a single todo
POST /todos {"title": "Buy milk"} Create a todo
PATCH /todos/:id {"title": "Buy milk updated"} Update a todo
DELETE /todos/:id Delete a todo

Try it with curl, Postman, or your future frontend.


📁 Project Structure

src/
├── app.module.ts             # Root module
├── app.controller.ts         # Root controller
├── main.ts                   # App entry point
├── common/                   # Shared utilities
│   ├── decorators/           # @CurrentUser, etc.
│   └── guards/               # JwtAuthGuard
├── core/
│   └── prisma/               # Prisma module & service (singleton)
└── modules/
    ├── auth/                 # Auth module (register, login, JWT)
    └── todo/                 # Todo CRUD module

prisma/
├── schema.prisma             # Database schema
└── migrations/               # Prisma migration files
Enter fullscreen mode Exit fullscreen mode

Everything is intentionally minimal so you can understand and extend it with confidence.


💡 Notes

  • Singleton Prisma client – The PrismaService reuses a single client instance across serverless invocations to avoid exhausting database connections.
  • Never commit .env – use .env.example as a safe template for your team.
  • Best for – hobby projects, small startups, hackathons, or as a learning base. Need rate limiting or more complex logic? The architecture is clean enough to scale with your needs.

Top comments (0)