Deploy Node.js application to Vercel in 5 minutes

·

2 min read

Introduction

Deploying a Node.js application to Vercel can be easily done by just adding a vercel.json configuration file to your project root directory.

Here I will show you how it can be achieved.

Add vercel.json file

First of all, add a vercel.json file in the root directory of your existing Node.js project. Add and commit the file to the Git repository.

{
   "version": 2,
   "name": "music-album",
   "builds": [
      { "src": "app.js", "use": "@vercel/node" }
   ],
   "routes": [
      { "src": "/(.*)", "dest": "/app.js" }
   ]
}

Create a Vercel project

  1. Login Vercel.

    If you don't have an account yet, you can sign up for a free account.

  2. Click the "+ New Project" button on the Overview tab.

    New Project

  3. Import Git Repository by selecting the Git provider. GitHub, GitLab and Bitbucket are available.

    Import GIt Repo

  4. Import Git Repository.

    Import GIt Repo

  5. Configure the project.

    1. Give a Project Name.
    2. Click the "Deploy" button. The deployment should be triggered.

      Configure Project

  6. Check the deployment status.

    Check deployment

  7. Click the link under DOMAINS to view the application in browser.

    View deployment

Conclusion

Congratulations! Your Node.js application is now configured to be deployed to Vercel easily by adding a configuration file to the project.

References

  1. Source code in GitHub
  2. Live demo at Vercel