How to Deploy a NestJS App on Vercel – The Simple Guide (Deploy API on Vercel)
Nurul Islam Rimon

Nurul Islam Rimon @nurulislamrimon

About: Thanks for being here! I'm Nurul Islam Rimon, a MERN & PERN stack developer. I'm a student of competitive programming. I love to explore new technology.

Location:
Chaprashirhat, Kabirhat, Noakhali
Joined:
Jan 20, 2024

How to Deploy a NestJS App on Vercel – The Simple Guide (Deploy API on Vercel)

Publish Date: Apr 21
10 0

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
Enter fullscreen mode Exit fullscreen mode

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"]
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Run:

vercel .
Enter fullscreen mode Exit fullscreen mode

Follow the prompts — done!

Option B: Through GitHub

  1. Push your code to GitHub.
  2. Go to vercel.com, click “New Project”.
  3. 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
Enter fullscreen mode Exit fullscreen mode

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

Comments 0 total

    Add comment