Want to deploy your NestJS backend on Vercel? Great choice! Vercel is super fast and easy to use, and it supports serverless apps out of the box. Here’s a step-by-step guide to help you get your NestJS app live in minutes.
What You’ll Need
- Node.js installed
- A NestJS project (nest new my-app)
- A GitHub account
- A Vercel account
Step 1: Create Your NestJS App
If you haven’t created your app yet:
npm i -g @nestjs/cli
nest new my-app
cd my-app
Step 2: Add vercel.json File
In the root of your project, create a file called vercel.json.
{
"version": 2,
"builds": [
{
"src": "src/main.ts",
"use": "@vercel/node"
}
],
"routes": [
{
"src": "/(.*)",
"dest": "src/main.ts",
"methods": ["GET", "POST", "PUT", "PATCH", "DELETE"]
}
]
}
This tells Vercel how to build and route your app.
Step 5: Deploy to Vercel
Option A: With Vercel CLI
Install Vercel CLI:
npm i -g vercel
Run:
vercel .
Follow the prompts — done!
Option B: Through GitHub
- Push your code to GitHub.
- Go to vercel.com, click “New Project”.
- Import your repo, and Vercel handles the rest.
That’s It!
Your NestJS app is now deployed on a URL like:
https://your-project-name.vercel.app
Tips
- Use .env for secrets → add them in Vercel's settings.
- Keep api/index.ts minimal — it’s your serverless function.
- Use vercel dev to test locally like production.
Regards,
N I Rimon