Deploy your NodeJS backend application with Vercel

Raj Lanjewar
3 min readDec 3, 2023

--

Prerequisite:

  1. Active Vercel account (if not create here)
  2. GitHub account (if not create here)
  3. NodeJS installed (if not download from here) official documentation recommends having NodeJS version 16 or above.

Let’s create a new Nest JS application

npm install @nestjs/cli
nest new HelloNestJS
install Nest JS CLI
Scaffold new project with nest new command

Add your newly created project code to GitHub.

And create one file name: vercel.json in your project root folder (where you have your package.json file) and add the below lines and save.

{
"version": 2,
"builds": [
{
"src": "src/main.ts",
"use": "@vercel/node"
}
],
"routes": [
{
"src": "/(.*)",
"dest": "src/main.ts",
"methods": [
"GET",
"POST",
"PUT",
"DELETE"
]
}
]
}

vercel.json file is vercel custom configuration file used then we deploy our project to vercel.

You can read more configuration options here Configuring Projects with vercel.json

Method 1: Vercel Dashboard

Login to Vercel account and Add New project

Vercel.com Dashboard

In the next page import your git repository and then on next page click on Import

Import your project to Vercel.com dashboard
Import Github repository to Vercel.com
Start Verrcel.com deployment

Leave the setting as default and click on Deploy. You will be able to see the live deployment process in action. And in a couple of minutes you will get your live link of your application, Congratulations! You have deployed your Nest JS application with Vercel service and now you are able to test and share with your friends.

Final step Deploy

Method 2: Command line

We need to install one npm package called vercel. Run below command on command prompt.

npm install -g vercel

Then next run command

vercel .
Vercel command line tool

If you are first time running this command then you must have to run

vercel login

Command and you will be redirected to the login screen of vercel complete the login and visit the command prompt and then run

vercel .

You will be prompting to couple of question, pick the options and hit enter and soon you will get couple of links of your deployed application

One is your main application link and another is you can inspect/monitor your application running logs.

Hooray! you deployed your backend Nest JS application successfully now, test, share your creativity with your friends and enjoy!

My deployed version of application: https://nest-j-scaffold.vercel.app/

--

--

Raj Lanjewar

I am a travel enthusiast, technical YouTube video creator, and nature lover, loves book reading.