Auto Deploy NodeJS App Using Vercel

Tram Ho

Hi everybody,

Today I will show everyone how to auto deploy a NodeJS application.

Come on, let’s get started.


1. First let’s find out what vercel is

  • Vercel is a cloud platform created for quick and easy web application development and deployment. This platform allows you to build, deploy, and manage web applications without worrying about server configuration.
  • Vercel supports web applications written in many programming languages, such as JavaScript, TypeScript, Python, Go, and many more.

2. Proceed to create project and deploy

Step 1: Access the link and log in https://vercel.com/

  • We can login with our github/gitlab account to connect to our repository.

B2: Connect to the repository containing the project to deploy

  • After successfully logging in, we select Add new -> Project. At this time, the interface displays as follows We can connect to the repository in our Github/Gitlab account or import it using the url Let’s say here we connect to the FoonGo repo.

B3: Configure the project to deploy

  • After linking the project to the repo then config project
  • In Environment variables, we proceed to enter the key and value corresponding to the .env file in our project

B4; Deployment

However, this is not enough, we need to take the following steps to auto deploy when a branch on Github/Gitlab changes.


  • In package.json add the following code:

*file package.json

image.png

Tạo 1 file vercel.json để chứa script config vercel

Then we push to Github with the repo connected to the above vercel

Finally, we go back to the FoodnGo project created on vercel earlier to change the branch we want to auto deploy

image.png

  • Select the branch that you want to auto-deploy when it changes.
  • For me, I choose develop because our GITFLOW will create pull requests from feature_branch and then create pull requests to merge into develop.
  • So for each function merged into develop on Github, it will automatically redeploy to vercel**

Now, choose to redeploy the project again

image.png

Done, Now your NodeJs App project is automatically deployed every time there is a change in develop branch image.png


Hope the article brings useful knowledge to you.

Chia sẻ bài viết ngay

Nguồn bài viết : Viblo