Deploying Express App on Render or Vercel

📘 Express.js 👁 45 views 📅 Nov 05, 2025
⏱ Estimated reading time: 2 min

Render is a cloud platform that can host Node.js backend apps easily.

1. Prepare Your Express App

  • Ensure your project has package.json with start script:

"scripts": { "start": "node app.js" }
  • Use environment variables for secrets and ports:

const PORT = process.env.PORT || 3000; app.listen(PORT, () => console.log(`Server running on port ${PORT}`));

2. Push Code to Git

  • Create a Git repository and push your code to GitHub, GitLab, or Bitbucket:

git init git add . git commit -m "Initial commit" git remote add origin git push -u origin main

3. Create Render Web Service

  1. Go to Render Dashboard → Click New → Web Service

  2. Connect your Git repository

  3. Select Node environment

  4. Set Build Command: npm install

  5. Set Start Command: npm start

  6. Set Environment Variables (PORT is usually automatic)

  7. Click Create Web Service

Render will build and deploy your Express app.

  • Your app will have a public URL like: https://your-app.onrender.com


4. Optional: Connect a Database

  • Render supports PostgreSQL, MySQL, and Redis

  • Set the database connection string in environment variables


Deploying Express.js App on Vercel

Vercel is mainly for serverless functions, but you can deploy an Express app as an API.

1. Install Vercel CLI

npm install -g vercel

2. Prepare Express App for Serverless

  • Create api/index.js:

const express = require('express'); const serverless = require('serverless-http'); const app = express(); app.use(express.json()); app.get('/', (req, res) => { res.send('Hello from Express on Vercel!'); }); module.exports.handler = serverless(app);
  • Install serverless-http:

npm install serverless-http
  • Update package.json scripts:

"scripts": { "start": "node api/index.js" }

3. Deploy to Vercel

vercel login vercel
  • Vercel will guide you through deployment

  • App will be deployed as serverless functions: https://your-app.vercel.app/api


5. Environment Variables on Vercel

  • Go to Project Settings → Environment Variables

  • Add variables like DB_URI, JWT_SECRET, etc.

  • Use process.env.VARIABLE_NAME in your Express app


6. Best Practices for Deployment

  1. Use environment variables for secrets

  2. Use HTTPS (Vercel and Render provide it by default)

  3. Keep serverless functions lightweight (for Vercel)

  4. Use persistent storage (Render database or cloud DB)

  5. Monitor logs and errors after deployment


Summary

PlatformApproachNotes
RenderFull backend web serviceBest for full Express apps
VercelServerless API (serverless-http)Good for lightweight APIs and functions

🔒 Some advanced sections are available for Registered Members
Register Now

Share this Post


← Back to Tutorials

Popular Competitive Exam Quizzes