Deploying Express Backend to Vercel
A step-by-step guide on how to deploy a Node.js + Express backend to Vercel.
Tech Stack
- Node.js 16
- Express 4.18.2
- Vercel Serverless Functions
Introduction
Deploying web applications often demands a hosting platform that balances simplicity, scalability, and performance. In this post, we’ll walk you through how to deploy an Express.js backend to Vercel — a popular serverless platform — using a minimal setup. This approach works whether you're starting from scratch or transitioning an existing Node.js backend to a serverless environment.
Steps
1. Create the Express API
mkdir server
cd server
npm init -y
npm install expressThen create a file called app.js:
const express = require("express");
const app = express();
const PORT = 8000;
app.get("/", (req, res) => {
res.send("Hello World");
});
app.get("/about", (req, res) => {
res.send("About route");
});
app.listen(PORT, () => {
console.log(`✅ Server is running on port ${PORT}`);
});2. Add Vercel configuration
Create a vercel.json file at the root (or appropriate) level:
{
"version": 2,
"builds": [
{
"src": "app.js",
"use": "@vercel/node",
"config": { "includeFiles": ["dist/**"] }
}
],
"routes": [
{
"src": "/(.*)",
"dest": "app.js"
}
]
}Also ensure your package.json has the start script:
{
"name": "server",
"version": "1.0.0",
"main": "app.js",
"scripts": {
"start": "node app.js"
},
"dependencies": {
"express": "^4.18.2"
}
}3. Push to GitHub
- Initialize a git repository
- Add files (
git add .) - Commit (
git commit -m "Initial commit") - Push to a GitHub repo
4. Connect to Vercel & Deploy
- Go to your Vercel dashboard
- “Import Project” → select your GitHub repo
- Vercel will automatically detect the project configuration and deploy your backend
- Once deployment completes, your backend will be live (e.g. https://your-project.vercel.app)
Notes & Considerations
- On Vercel, static assets should be placed in a
public/folder (rather than relying onexpress.static). - If you prefer, you can also structure your project so the server entry is under
/api— Vercel will treat files there as serverless functions. - For more complex apps (e.g. database, environment variables, middleware), ensure all configs are properly set — Vercel’s serverless environment has constraints (function size, cold start, resource limits) to keep in mind.
Summary
Deploying an Express backend on Vercel can be quick and straightforward:
- Initialize a Node + Express project
- Configure vercel.json to let Vercel treat your app as a serverless function
- Push to GitHub, connect and deploy via Vercel
This approach helps you leverage serverless benefits — scalability, simplified deployment, and minimal infrastructure overhead.
Read the full article on Medium → Deploying Express Backend to Vercel