DEV Community

Cover image for How to Deploy a Node.js App to Vercel
Ilyas Abdisalam
Ilyas Abdisalam

Posted on

How to Deploy a Node.js App to Vercel

This tutorial will show you how to deploy a simple Node.js (Express) app to Vercel. Itโ€™s perfect for beginners who want to get their API online fast โ€” without worrying about infrastructure.


๐Ÿงฐ Prerequisites

Before you start, make sure you have the following installed:

  • โœ… Node.js and npm on your system
  • โœ… Git installed
  • โœ… GitHub account
  • โœ… Basic knowledge of JavaScript and Node.js

๐Ÿ› ๏ธ Step 1: Create a Simple Node.js App

Open your terminal and run the following commands:

mkdir my-app
cd my-app
npm init -y
npm install express
Enter fullscreen mode Exit fullscreen mode

This creates a new folder, initializes a Node.js project, and installs Express.js.

๐Ÿ“ Step 2: Create index.js

Inside your project folder, create a file called index.js and add the following code:

const express = require('express');
const app = express();

app.get('/', (req, res) => {
  res.send('Hello, Vercel!');
});

app.listen(3000, () => {
  console.log('Server is running on http://localhost:3000');
});
Enter fullscreen mode Exit fullscreen mode

This sets up a basic Express server that responds with "Hello, Vercel!".

๐Ÿงช Step 3: Test the App Locally

Run the app locally to make sure everything works:

node index.js
Enter fullscreen mode Exit fullscreen mode

Visit http://localhost:3000 in your browser โ€” you should see:

Hello, Vercel!

๐Ÿš€ Step 4: Prepare for Deployment

  1. Create a .gitignore file and ignore node_modules:
echo node_modules > .gitignore
Enter fullscreen mode Exit fullscreen mode
  1. Initialize a git repository and push it to GitHub:
git init
git add .
git commit -m "Initial commit"
git branch -M main
git remote add origin https://github.com/YOUR_USERNAME/YOUR_REPO_NAME.git
git push -u origin main
Enter fullscreen mode Exit fullscreen mode

๐ŸŒ Step 5: Deploy to Vercel

  1. Go to https://vercel.com and sign in with your GitHub account.
  2. Click "New Project".
  3. Import your repository.
  4. Leave all settings as default and click "Deploy".

Wait a few momentsโ€ฆ and voilร ! Your Node.js app is live โœจ

โœ… Conclusion

Youโ€™ve just built and deployed a Node.js app to the web using Express and Vercel. From here, you can:

  • Build APIs and connect to databases
  • Add frontend frameworks like React or Vue

Top comments (0)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.