Deploying Express App on Render or Vercel
⏱ 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.jsonwithstartscript:
-
Use environment variables for secrets and ports:
2. Push Code to Git
-
Create a Git repository and push your code to GitHub, GitLab, or Bitbucket:
3. Create Render Web Service
-
Go to Render Dashboard → Click New → Web Service
-
Connect your Git repository
-
Select Node environment
-
Set Build Command:
npm install -
Set Start Command:
npm start -
Set Environment Variables (PORT is usually automatic)
-
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
2. Prepare Express App for Serverless
-
Create
api/index.js:
-
Install
serverless-http:
-
Update
package.jsonscripts:
3. Deploy to 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_NAMEin your Express app
6. Best Practices for Deployment
-
Use environment variables for secrets
-
Use HTTPS (Vercel and Render provide it by default)
-
Keep serverless functions lightweight (for Vercel)
-
Use persistent storage (Render database or cloud DB)
-
Monitor logs and errors after deployment
Summary
| Platform | Approach | Notes |
|---|---|---|
| Render | Full backend web service | Best for full Express apps |
| Vercel | Serverless API (serverless-http) | Good for lightweight APIs and functions |
Register Now
Share this Post
← Back to Tutorials