Vercel deployment management for frontend apps: CLI, env vars, config, troubleshooting, rollback.
Skill Type: Deployment Management For Agent: @shawar-2.0 Platform: Vercel (Frontend Hosting)
This skill enables Vercel deployment management for React/Next.js frontends including project configuration, environment variables, domain management, and build optimization.
Login & Project Setup:
# Login to Vercel
vercel login
# Link to existing project
vercel link
# Check current project
vercel ls
Deployment:
# Deploy to preview (staging)
vercel
# Deploy to production
vercel --prod
# Deploy specific directory
vercel ./frontend --prod
# Check deployment status
vercel ls
Environment Variables:
# Add environment variable
vercel env add [KEY]
# List all environment variables
vercel env ls
# Pull environment variables to .env.local
vercel env pull
# Remove environment variable
vercel env rm [KEY]
Domain Management:
# List domains
vercel domains ls
# Add domain
vercel domains add [domain]
# Remove domain
vercel domains rm [domain]
Logs & Monitoring:
# View deployment logs
vercel logs [deployment-url]
# List recent deployments
vercel ls
# Inspect deployment
vercel inspect [deployment-url]
Typical React Frontend:
npm run build or yarn builddist (Vite) or .next (Next.js)npm install or yarn installEnvironment Variables to Configure:
VITE_API_URL - Backend API URL (Railway service)VITE_ENVIRONMENT - development, staging, or productionVITE_ANTHROPIC_API_KEY - (if frontend calls Claude directly)Vercel Environment Scopes:
Production - Main branch deploymentsPreview - Feature branch deploymentsDevelopment - Local developmentStandard Deployment Process:
Branch to Environment Mapping:
development branch → Preview deploymentstaging branch → Staging/Preview deploymentmain branch → Production deployment{{PROJECT_NAME}} Domain Defaults:
https://{{FRONTEND_URL}} (primary; https://missioninbox.in redirects)https://{{STAGING_FRONTEND_URL}} (Preview mapped to staging branch)q.metadata?.priority when metadata was Record<string, unknown> produced Type 'unknown' is not assignable to type 'ReactNode'. Fix by defining a typed metadata interface and narrowing to string before rendering.pnpm run build in frontend-nextjs to get exact TS errors.vercel.json (at project root):
{
"buildCommand": "npm run build",
"outputDirectory": "dist",
"framework": "vite",
"rewrites": [
{
"source": "/(.*)",
"destination": "/index.html"
}
],
"headers": [
{
"source": "/(.*)",
"headers": [
{
"key": "X-Content-Type-Options",
"value": "nosniff"
},
{
"key": "X-Frame-Options",
"value": "DENY"
},
{
"key": "X-XSS-Protection",
"value": "1; mode=block"
}
]
}
]
}
vite.config.ts (for React + Vite):
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
export default defineConfig({
plugins: [react()],
build: {
outDir: 'dist',
sourcemap: true
},
server: {
port: 3000
}
})
After Every Deployment:
# Check deployment status
vercel ls
# Test deployment URL
curl https://[deployment-url]
# Test API integration
# Open browser DevTools, check Network tab for backend calls
Health Check Success Criteria:
Common Issues:
Issue: Build fails with "Module not found"
package.json has all dependenciesIssue: "404 Not Found" on page refresh
vercel.json has rewrite rules for SPA routing"source": "/(.*)", "destination": "/index.html"Issue: Environment variables not working
VITE_ for Vite, NEXT_PUBLIC_ for Next.js)VITE_* or NEXT_PUBLIC_*)Issue: CORS errors when calling backend
CORS_ORIGINS includes Vercel domainIssue: Build exceeds time limit
Issue: Assets not loading (404 for CSS/JS)
dist vs .next)If Deployment Fails:
Vercel Instant Rollback:
# List recent deployments
vercel ls
# Promote previous deployment to production
vercel promote [previous-deployment-url] --prod
Git Rollback:
git revert [bad-commit-hash]
git push origin [branch-name]
# Vercel will auto-deploy the revert
vercel.jsonWith Railway (Backend):
VITE_API_URL points to Railway domainWith Git:
With GitHub:
Key Sections:
URLs:
https://vercel.com/[team]/[project]https://vercel.com/[team]/[project]/deploymentsVercel Edge Network:
Build Optimization:
# Analyze bundle size
npm run build -- --analyze
# Enable minification (usually default)
# Check vite.config.ts or next.config.js
Caching Strategy:
{
"headers": [
{
"source": "/assets/(.*)",
"headers": [
{
"key": "Cache-Control",
"value": "public, max-age=31536000, immutable"
}
]
}
]
}
Deployment is successful when:
Deploy to production:
vercel --prod
Check deployment status:
vercel ls
Update environment variable:
vercel env add VITE_API_URL
# Enter value when prompted
# Then redeploy to apply
Instant rollback:
vercel ls
vercel promote [previous-url] --prod
Monitor logs:
vercel logs [deployment-url]
Production:
Staging:
Preview (per-branch):
Last Updated: 2025-11-23
Maintained By: @shawar-2.0
Related Skill: railway-deploy.md
scripts/skill_info.py: Print skill name and description.