This guide will walk you through deploying SkillBridge AI to Vercel with both frontend (React) and backend (Express API) running as serverless functions.
- GitHub account
- Vercel account (free tier works perfectly)
- MongoDB Atlas account (free tier)
- All API keys ready (Firebase, Google Maps, Gemini AI)
Vercel Deployment
├── Frontend (React + Vite) → served at /
└── Backend (Express API) → served at /api/*
- Frontend: Static React SPA built with Vite
- Backend: Express routes converted to Vercel serverless functions
- Database: MongoDB Atlas (connection pooling implemented)
- Same Domain: No CORS issues! Everything runs on same domain
-
Go to MongoDB Atlas
-
Create a free cluster (if you haven't already)
-
Go to Network Access → Add IP Address → 0.0.0.0/0 (Allow from anywhere)
-
Go to Database Access → Create a database user
-
Get your connection string:
mongodb+srv://username:password@cluster.mongodb.net/skillbridge
# If not already a git repo, initialize
git init
# Add all files
git add .
# Commit
git commit -m "Prepare for Vercel deployment"
# Create GitHub repo and push
git remote add origin https://github.com/yourusername/skillbridge-ai.git
git branch -M main
git push -u origin main- Go to vercel.com
- Click New Project
- Import your GitHub repository
- Configure:
- Framework Preset: Vite
- Root Directory:
./(leave as is) - Build Command:
npm run build(auto-detected) - Output Directory:
dist(auto-detected)
# Install Vercel CLI
npm i -g vercel
# Deploy
vercel
# Follow prompts
# Select settings (auto-detected)Go to Vercel Dashboard → Your Project → Settings → Environment Variables
Add ALL of these (for Production, Preview, and Development):
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/skillbridge
JWT_SECRET=your_super_secret_jwt_key_min_32_characters
JWT_EXPIRE=30d
NODE_ENV=production
VITE_GOOGLE_MAPS_API_KEY=your_google_maps_api_key
VITE_FIREBASE_API_KEY=your_firebase_api_key
VITE_FIREBASE_AUTH_DOMAIN=your-project.firebaseapp.com
VITE_FIREBASE_PROJECT_ID=your-project-id
VITE_FIREBASE_STORAGE_BUCKET=your-project.appspot.com
VITE_FIREBASE_MESSAGING_SENDER_ID=your_sender_id
VITE_FIREBASE_APP_ID=your_app_id
API_KEY=your_gemini_api_key
Important: Make sure to add these to ALL environments (Production, Preview, Development)
After adding environment variables:
- Go to Deployments tab
- Click Redeploy on the latest deployment
- Check Use existing Build Cache (optional)
- Click Redeploy
Once deployed, test these URLs:
https://your-app.vercel.app
https://your-app.vercel.app/api/health
Should return:
{
"success": true,
"message": "SkillBridge API is running on Vercel",
"timestamp": "2026-01-24T...",
"environment": "production"
}POST https://your-app.vercel.app/api/auth/login
POST https://your-app.vercel.app/api/auth/signup
Error: MongoNetworkError or ECONNRESET
Solution:
- Verify MongoDB Atlas Network Access allows
0.0.0.0/0 - Check connection string is correct (no spaces, correct password)
- Ensure environment variables are set in Vercel
Error: 404 Not Found on /api/*
Solution:
- Check
vercel.jsonis in root directory - Verify
api/index.jsexists - Check Vercel build logs for errors
Error: undefined for environment variables
Solution:
- Ensure variables are added to ALL environments in Vercel
- Redeploy after adding variables
- Frontend variables MUST start with
VITE_
Error: Build fails on Vercel
Solution:
- Check Vercel build logs
- Ensure all dependencies are in
package.json - Try local build:
npm run build
- Connection Pooling: Already implemented in
/api/lib/db.js - Cold Starts: First request may be slow (~500ms), subsequent requests are fast
- Caching: Vercel automatically caches static assets
- Edge Network: Your app is served from Vercel's global CDN
- ✅ Never commit
.envor.env.localfiles - ✅ Use strong JWT secrets (min 32 characters)
- ✅ Rotate API keys if exposed
- ✅ Enable MongoDB IP whitelist (or use 0.0.0.0/0 for Vercel)
- ✅ Set up Firebase security rules
- View real-time logs
- Monitor function invocations
- Track performance metrics
vercel logs your-app.vercel.app --followEvery push to main branch will automatically:
- Trigger a new Vercel build
- Run tests (if configured)
- Deploy to production
- Previous deployment remains accessible
Your SkillBridge AI app is now:
- ✅ Deployed globally on Vercel's Edge Network
- ✅ Running serverless backend functions
- ✅ Connected to MongoDB Atlas
- ✅ Using Firebase Authentication
- ✅ Integrated with Google Maps & Gemini AI
Share your live URL: https://your-app.vercel.app 🎊
If you encounter issues:
- Check Vercel build logs
- Verify environment variables
- Test API endpoints with
/api/health - Review MongoDB Atlas connection settings