How to Deploy Node Express API to Vercel Serverless Functions

JonathanSanchez.Dev
3 min readJul 7, 2022

--

So you’ve built an awesome API in your local machine with Express using Node.js and you are ready for clients and your parents to be proud of you?

Well, you need to push your API to the cloud, aka production.

Then you run into the plethora of options Azure, Google Cloud Platform, AWS, Heroku, etc…….

for deploy on AWS — checkout this medium How to deploy Node Express API to EC2 instance in AWS

But wait did you know you could also deploy your API to Vercel? Not only deploy but it will even listen when you push your changes to your main Git Branch.

Pre-requisites:

  1. Vercel Free account — https://vercel.com/signup
  2. If you don’t have NODE & NPM installed you need to 😊 check out this article
  3. Have or create an API (we’ll create a simple one if you don’t have one already)

Overview of steps:

  1. Create local Node Express API
  2. Connect local API to a Github repo
  3. Connect your Vercel account with that Github repo
  4. Update your repo locally then watch changes deploy immediately

Steps breakdown

1. Create Express API with NODE

  • Create a project directory, like mkdir node-api-vercel
  • Go into the new folder, with cd node-api-vercel
  • Initialize this folder as a Node project: npm init -y
  • Create files index.js, vercel.json, .gitignore files: touch index.js vercel.json .gitignore
  • Install Express.js: npm i express

Use these boilerplates for your .gitignore, index.js, vercel.json files

2. Connect local API folder to a Github repo

a. Create a repository in Github, node-api-vercel
b. Connect Repo in Github with your API following instructions in Github
c. Push API folder node-api-vercel to Github

3. Connect your Vercel account with that Github repo

a. Log into your Vercel account then click on New Project

Select the Repo
Deploy
Then congratulations
Find your app link on the dashboard

Link should look like this https://node-express-api-vercel.vercel.app/

You should see your API deployed

Enjoy…..🍻

Repo here

More details on what has happened here, Vercel takes the exported app and converts it to Serverless functions hosted in Vercel, for more info in regards visit https://vercel.com/guides/using-express-with-vercel

--

--

JonathanSanchez.Dev
JonathanSanchez.Dev

Written by JonathanSanchez.Dev

Developer by day, rockin' drummer by night. Loves dogs🐶 and collaborating with fellow engineers. Passionate, creative, and always up for a coding adventure! 🚀