Next.js
Beginner
1 min read
Deploying to Vercel
Example
# Deploy to Vercel via CLI
# Install the Vercel CLI globally
npm install -g vercel
# Log in to your Vercel account
vercel login
# Deploy from the project directory
# First run: interactive setup, links to a Vercel project
vercel
# Deploy to production explicitly
vercel --prod
# Pull environment variables to a local .env.local file
vercel env pull .env.local
# List all deployments for the current project
vercel ls
# Inspect a specific deployment
vercel inspect <deployment-url>
# Roll back to the previous production deployment
vercel rollback
# Example vercel.json for custom configuration
# (most settings go in next.config.js — vercel.json is for edge cases)
// vercel.json
{
"headers": [
{
"source": "/(.*)",
"headers": [
{ "key": "X-Content-Type-Options", "value": "nosniff" },
{ "key": "X-Frame-Options", "value": "DENY" },
{ "key": "Referrer-Policy", "value": "strict-origin-when-cross-origin" }
]
}
],
"regions": ["iad1", "lhr1"]
}