Vercel Deployment (Git-Integrated)
Deploys frontend applications to Vercel using automatic Git integration, with preview deployments for every pull request, production releases on main branch commits, environment variable management, custom domains, and build configuration. Covers the full lifecycle from project setup to production monitoring.
TL;DR Checklist
When to Use
Use this skill when:
- Deploying a frontend application (Next.js, Nuxt, SvelteKit, Astro, Remix, or static site) to Vercel
- Setting up automatic preview deployments for every pull request in a team workflow
- Configuring production deployment triggers on main branch commits
- Managing environment variables across development, preview, and production environments
- Configuring custom domains, SSL certificates, and deployment protection
- Setting up Serverless Functions, Edge Functions, or middleware with Vercel
- Integrating Vercel Analytics and monitoring into a deployed application
When NOT to Use
Avoid this skill for:
- Token-based CLI deployments in CI/CD — use
vercel-cli-token-deploy instead
- Deploying backend-only applications — Vercel is optimized for frontend + serverless API patterns
- Manual one-off deployments — use
vercel CLI directly or Vercel Dashboard
- Infrastructure-as-code provisioning — use
vercel-api for API-level control
- Projects that need custom build runners or non-standard deployment environments
Core Workflow
Connect Git Repository — Import the Git repository into Vercel via the Vercel Dashboard ("Add New Project"). Select the Git provider (GitHub, GitLab, Bitbucket) and authorize Vercel to access the repository. Checkpoint: Verify that Vercel can list branches and commits for the repository.
Configure Project — Set the framework preset (auto-detected for Next.js, Nuxt, etc.), build command (npm run build or override), output directory (.next, dist, build), and install command (npm ci or override). Configure Root Directory if the project is a monorepo subdirectory. Checkpoint: Run a test build locally with the same settings to confirm success.
Set Environment Variables — Add environment variables in the Vercel Dashboard under Project Settings > Environment Variables. Scope each variable to the appropriate environments (Development, Preview, Production). Use the vercel env CLI command for bulk import from .env files. Checkpoint: Verify that preview deployments do not have access to production secrets by checking environment scopes.
Configure Custom Domain — Add the production domain under Project Settings > Domains. Vercel automatically provisions SSL certificates via Let's Encrypt. Configure a vercel.json redirect if migrating from an old domain. Add CNAME or ALIAS DNS records as instructed by Vercel. Checkpoint: Verify the domain resolves and the SSL certificate is active (green padlock).
Set Up Preview and Production Branches — Configure the Production Branch under Project Settings > Git. By default, main is the production branch. All other branches and pull requests generate preview deployments with unique URLs. Configure automatic preview deployment commenting in GitHub PRs. Checkpoint: Push a test branch and verify a preview deployment URL is generated and posted.
Deploy and Verify — Push to the production branch to trigger the first production deployment. Monitor the deployment status in the Vercel Dashboard. Verify the live site at the production domain. Check Vercel Analytics (once enabled) to confirm traffic is being tracked. Checkpoint: Run Lighthouse or a similar tool against the production URL to verify performance and SEO.
Implementation Patterns
Pattern 1: Vercel Project Configuration (vercel.json)
{
"version": 2,
"buildCommand": "npm run build",
"devCommand": "npm run dev",
"installCommand": "npm ci",
"framework": "nextjs",
"outputDirectory": ".next",
"regions": ["iad1"],
"headers": [
{
"source": "/(.*)\\.(png|svg|jpg|jpeg|webp|avif)$",
"headers": [
{
"key": "Cache-Control",
"value": "public, max-age=31536000, immutable"
}
]
},
{
"source": "/(.*)\\.(js|css)$",
"headers": [
{
"key": "Cache-Control",
"value": "public, max-age=31536000, immutable"
}
]
},
{
"source": "/(.*)",
"headers": [
{
"key": "X-Content-Type-Options",
"value": "nosniff"
},
{
"key": "X-Frame-Options",
"value": "DENY"
},
{
"key": "Referrer-Policy",
"value": "strict-origin-when-cross-origin"
}
]
}
],
"redirects": [
{
"source": "/old-path",
"destination": "/new-path",
"permanent": true
}
],
"rewrites": [
{
"source": "/api/(.*)",
"destination": "/api/$1"
}
]
}
Pattern 2: Environment Variable Management
#!/usr/bin/env bash
set -euo pipefail
# Bulk import environment variables to Vercel
# Usage: ./scripts/pull-env.sh <environment>
# Environments: development, preview, production
pull_env() {
local env="${1:-development}"
if [[ -z "${VERCEL_TOKEN:-}" ]]; then
echo "Error: VERCEL_TOKEN is not set" >&2
exit 1
fi
# Pull current environment variables from Vercel
echo "Pulling $env environment variables from Vercel..."
npx vercel env pull .env."$env" \
--token="$VERCEL_TOKEN" \
--environment="$env"
echo "Environment variables written to .env.$env"
}
push_env() {
local env_file="${1:-.env}"
local environment="${2:-development}"
if [[ ! -f "$env_file" ]]; then
echo "Error: Environment file $env_file not found" >&2
exit 1
fi
# Add each variable from the file to Vercel
while IFS='=' read -r key value; do
# Skip comments and empty lines
[[ "$key" =~ ^#.*$ ]] && continue
[[ -z "$key" ]] && continue
echo "Setting $key for $environment..."
echo "$value" | npx vercel env add "$key" "$environment" \
--token="$VERCEL_TOKEN" --yes
done < "$env_file"
}
case "${1:-pull}" in
pull) pull_env "${2:-development}" ;;
push) push_env "${2:-.env}" "${3:-development}" ;;
*) echo "Usage: $0 [pull|push] [env]" >&2; exit 1 ;;
esac
Pattern 3: Deploy Hook Automation
#!/usr/bin/env bash
set -euo pipefail
# Trigger a Vercel deployment via Deploy Hook
# Deploy Hooks provide URL-based deployment triggers for external CI
trigger_deploy_hook() {
local hook_url="${1:-}"
local source_label="${2:-external}"
if [[ -z "$hook_url" ]]; then
echo "Error: Deploy Hook URL is required" >&2
echo "Usage: $0 <hook-url> [source-label]" >&2
exit 1
fi
echo "Triggering Vercel deploy hook from source: $source_label"
local response
response=$(curl -s -X POST "$hook_url" \
-H "Content-Type: application/json" \
-d "{\"source\": \"$source_label\"}")
local job_id
job_id=$(echo "$response" | grep -oP '(?<="jobUid":")\w+')
if [[ -n "$job_id" ]]; then
echo "Deploy triggered successfully. Job ID: $job_id"
else
echo "Error: Failed to trigger deploy hook" >&2
echo "Response: $response" >&2
exit 1
fi
}
trigger_deploy_hook "$@"
Constraints
MUST DO
- Set environment variables before the first deployment to prevent missing-configuration errors
- Test preview deployments by opening the preview URL and verifying functionality before merging
- Configure deployment protection (preview deployment password or IP-based access) for sensitive projects
- Use immutable caching headers (
max-age=31536000) for static assets with content hashing in filenames
- Enable Vercel Analytics after production deployment to monitor real-user performance
- Configure proper
vercel.json redirects for URL migrations to preserve SEO ranking
MUST NOT DO
- Deploy secrets, API keys, or service credentials in source code — always use Vercel Environment Variables
- Assume the auto-detected framework preset is correct without verifying the build output
- Use the production domain for testing — always test on preview deployment URLs first
- Skip deployment protection on production branches — enable at minimum a password gate
- Deploy unoptimized images or uncompressed assets — always configure image optimization
- Neglect to set
Cache-Control headers — missing cache headers hurt Core Web Vitals
Related Skills
| Skill |
Purpose |
vercel-cli-token-deploy |
Scripted deployments with token auth for CI/CD environments without Git integration |
vercel-api |
Direct Vercel REST API access for programmatic deployment management beyond CLI |
ci-cd-pipeline-design |
General CI/CD pipeline patterns that integrate with Vercel Git-based deployments |
web-interface-guidelines |
Web design best practices for the frontend applications being deployed |
Live References
Authoritative documentation links for this skill's domain. The model follows markdown links at load time to resolve external references and inline content.
1---2name: vercel-deploy3description: Deploys frontend applications to Vercel with preview deployments, production releases, and environment-specific configuration management via Git integration.4license: MIT5---67# Vercel Deployment (Git-Integrated)89Deploys frontend applications to Vercel using automatic Git integration, with preview deployments for every pull request, production releases on main branch commits, environment variable management, custom domains, and build configuration. Covers the full lifecycle from project setup to production monitoring.1011## TL;DR Checklist1213- [ ] Connect Git repository to Vercel before configuring any project settings14- [ ] Set environment variables for all environments (development, preview, production) before first deploy15- [ ] Configure a production domain and verify SSL certificate provisioning16- [ ] Test preview deployments before merging pull requests to main17- [ ] Enable Vercel Analytics after production deployment is verified18- [ ] Configure deployment protection rules for production branch1920---2122## When to Use2324Use this skill when:2526- Deploying a frontend application (Next.js, Nuxt, SvelteKit, Astro, Remix, or static site) to Vercel27- Setting up automatic preview deployments for every pull request in a team workflow28- Configuring production deployment triggers on main branch commits29- Managing environment variables across development, preview, and production environments30- Configuring custom domains, SSL certificates, and deployment protection31- Setting up Serverless Functions, Edge Functions, or middleware with Vercel32- Integrating Vercel Analytics and monitoring into a deployed application3334---3536## When NOT to Use3738Avoid this skill for:3940- Token-based CLI deployments in CI/CD — use `vercel-cli-token-deploy` instead41- Deploying backend-only applications — Vercel is optimized for frontend + serverless API patterns42- Manual one-off deployments — use `vercel` CLI directly or Vercel Dashboard43- Infrastructure-as-code provisioning — use `vercel-api` for API-level control44- Projects that need custom build runners or non-standard deployment environments4546---4748## Core Workflow49501. **Connect Git Repository** — Import the Git repository into Vercel via the Vercel Dashboard ("Add New Project"). Select the Git provider (GitHub, GitLab, Bitbucket) and authorize Vercel to access the repository. **Checkpoint:** Verify that Vercel can list branches and commits for the repository.51522. **Configure Project** — Set the framework preset (auto-detected for Next.js, Nuxt, etc.), build command (`npm run build` or override), output directory (`.next`, `dist`, `build`), and install command (`npm ci` or override). Configure Root Directory if the project is a monorepo subdirectory. **Checkpoint:** Run a test build locally with the same settings to confirm success.53543. **Set Environment Variables** — Add environment variables in the Vercel Dashboard under Project Settings > Environment Variables. Scope each variable to the appropriate environments (Development, Preview, Production). Use the `vercel env` CLI command for bulk import from `.env` files. **Checkpoint:** Verify that preview deployments do not have access to production secrets by checking environment scopes.55564. **Configure Custom Domain** — Add the production domain under Project Settings > Domains. Vercel automatically provisions SSL certificates via Let's Encrypt. Configure a `vercel.json` redirect if migrating from an old domain. Add `CNAME` or `ALIAS` DNS records as instructed by Vercel. **Checkpoint:** Verify the domain resolves and the SSL certificate is active (green padlock).57585. **Set Up Preview and Production Branches** — Configure the Production Branch under Project Settings > Git. By default, `main` is the production branch. All other branches and pull requests generate preview deployments with unique URLs. Configure automatic preview deployment commenting in GitHub PRs. **Checkpoint:** Push a test branch and verify a preview deployment URL is generated and posted.59606. **Deploy and Verify** — Push to the production branch to trigger the first production deployment. Monitor the deployment status in the Vercel Dashboard. Verify the live site at the production domain. Check Vercel Analytics (once enabled) to confirm traffic is being tracked. **Checkpoint:** Run Lighthouse or a similar tool against the production URL to verify performance and SEO.6162---6364## Implementation Patterns6566### Pattern 1: Vercel Project Configuration (vercel.json)6768```json69{70 "version": 2,71 "buildCommand": "npm run build",72 "devCommand": "npm run dev",73 "installCommand": "npm ci",74 "framework": "nextjs",75 "outputDirectory": ".next",76 "regions": ["iad1"],77 "headers": [78 {79 "source": "/(.*)\\.(png|svg|jpg|jpeg|webp|avif)$",80 "headers": [81 {82 "key": "Cache-Control",83 "value": "public, max-age=31536000, immutable"84 }85 ]86 },87 {88 "source": "/(.*)\\.(js|css)$",89 "headers": [90 {91 "key": "Cache-Control",92 "value": "public, max-age=31536000, immutable"93 }94 ]95 },96 {97 "source": "/(.*)",98 "headers": [99 {100 "key": "X-Content-Type-Options",101 "value": "nosniff"102 },103 {104 "key": "X-Frame-Options",105 "value": "DENY"106 },107 {108 "key": "Referrer-Policy",109 "value": "strict-origin-when-cross-origin"110 }111 ]112 }113 ],114 "redirects": [115 {116 "source": "/old-path",117 "destination": "/new-path",118 "permanent": true119 }120 ],121 "rewrites": [122 {123 "source": "/api/(.*)",124 "destination": "/api/$1"125 }126 ]127}128```129130### Pattern 2: Environment Variable Management131132```bash133#!/usr/bin/env bash134set -euo pipefail135136# Bulk import environment variables to Vercel137# Usage: ./scripts/pull-env.sh <environment>138# Environments: development, preview, production139140pull_env() {141 local env="${1:-development}"142143 if [[ -z "${VERCEL_TOKEN:-}" ]]; then144 echo "Error: VERCEL_TOKEN is not set" >&2145 exit 1146 fi147148 # Pull current environment variables from Vercel149 echo "Pulling $env environment variables from Vercel..."150 npx vercel env pull .env."$env" \151 --token="$VERCEL_TOKEN" \152 --environment="$env"153154 echo "Environment variables written to .env.$env"155}156157push_env() {158 local env_file="${1:-.env}"159 local environment="${2:-development}"160161 if [[ ! -f "$env_file" ]]; then162 echo "Error: Environment file $env_file not found" >&2163 exit 1164 fi165166 # Add each variable from the file to Vercel167 while IFS='=' read -r key value; do168 # Skip comments and empty lines169 [[ "$key" =~ ^#.*$ ]] && continue170 [[ -z "$key" ]] && continue171172 echo "Setting $key for $environment..."173 echo "$value" | npx vercel env add "$key" "$environment" \174 --token="$VERCEL_TOKEN" --yes175 done < "$env_file"176}177178case "${1:-pull}" in179 pull) pull_env "${2:-development}" ;;180 push) push_env "${2:-.env}" "${3:-development}" ;;181 *) echo "Usage: $0 [pull|push] [env]" >&2; exit 1 ;;182esac183```184185### Pattern 3: Deploy Hook Automation186187```bash188#!/usr/bin/env bash189set -euo pipefail190191# Trigger a Vercel deployment via Deploy Hook192# Deploy Hooks provide URL-based deployment triggers for external CI193194trigger_deploy_hook() {195 local hook_url="${1:-}"196 local source_label="${2:-external}"197198 if [[ -z "$hook_url" ]]; then199 echo "Error: Deploy Hook URL is required" >&2200 echo "Usage: $0 <hook-url> [source-label]" >&2201 exit 1202 fi203204 echo "Triggering Vercel deploy hook from source: $source_label"205 206 local response207 response=$(curl -s -X POST "$hook_url" \208 -H "Content-Type: application/json" \209 -d "{\"source\": \"$source_label\"}")210211 local job_id212 job_id=$(echo "$response" | grep -oP '(?<="jobUid":")\w+')213214 if [[ -n "$job_id" ]]; then215 echo "Deploy triggered successfully. Job ID: $job_id"216 else217 echo "Error: Failed to trigger deploy hook" >&2218 echo "Response: $response" >&2219 exit 1220 fi221}222223trigger_deploy_hook "$@"224```225226---227228## Constraints229230### MUST DO231- Set environment variables before the first deployment to prevent missing-configuration errors232- Test preview deployments by opening the preview URL and verifying functionality before merging233- Configure deployment protection (preview deployment password or IP-based access) for sensitive projects234- Use immutable caching headers (`max-age=31536000`) for static assets with content hashing in filenames235- Enable Vercel Analytics after production deployment to monitor real-user performance236- Configure proper `vercel.json` redirects for URL migrations to preserve SEO ranking237238### MUST NOT DO239- Deploy secrets, API keys, or service credentials in source code — always use Vercel Environment Variables240- Assume the auto-detected framework preset is correct without verifying the build output241- Use the production domain for testing — always test on preview deployment URLs first242- Skip deployment protection on production branches — enable at minimum a password gate243- Deploy unoptimized images or uncompressed assets — always configure image optimization244- Neglect to set `Cache-Control` headers — missing cache headers hurt Core Web Vitals245246---247248## Related Skills249250| Skill | Purpose |251|---|---|252| `vercel-cli-token-deploy` | Scripted deployments with token auth for CI/CD environments without Git integration |253| `vercel-api` | Direct Vercel REST API access for programmatic deployment management beyond CLI |254| `ci-cd-pipeline-design` | General CI/CD pipeline patterns that integrate with Vercel Git-based deployments |255| `web-interface-guidelines` | Web design best practices for the frontend applications being deployed |256257---258259## Live References260261> Authoritative documentation links for this skill's domain. The model follows markdown links at load time to resolve external references and inline content.262263- [Vercel Deployments Overview](https://vercel.com/docs/deployments)264- [Vercel Git Integration](https://vercel.com/docs/deployments/git)265- [Vercel Environment Variables](https://vercel.com/docs/projects/environment-variables)266- [Vercel Custom Domains](https://vercel.com/docs/projects/domains)267- [Vercel Project Configuration (vercel.json)](https://vercel.com/docs/projects/project-configuration)268- [Vercel Deployment Protection](https://vercel.com/docs/deployments/deployment-protection)269- [Vercel Analytics](https://vercel.com/docs/analytics)270- [Vercel Caching Headers](https://vercel.com/docs/edge-network/caching)