Deploying to Vercel
Deploy your Astro site to Vercel with automatic deployments on every change.
Vercel is WP2Astro's integrated deployment platform, offering seamless hosting for your Astro sites with automatic builds, global CDN, and zero configuration required.
Why Vercel?
WP2Astro integrates directly with Vercel because:
- ✅ Automatic Deploys: Every push triggers a new deployment
- ✅ Global CDN: Serve from 100+ edge locations worldwide
- ✅ Zero Config: Detects Astro automatically
- ✅ Fast Builds: Optimized build infrastructure
- ✅ Free Tier: Generous limits for personal projects
- ✅ Custom Domains: Easy SSL and DNS management
- ✅ Preview Deployments: Test before going live
[screenshot of Vercel connection modal]
Setting Up Vercel
Step 1: Connect Vercel Account
From your WP2Astro dashboard:
- Look for the "Deploy to Vercel" section in the sidebar
- Click "Connect Vercel"
- You'll see a modal with two options:
Option A: Connect with Vercel OAuth
- Click "Connect Vercel Account"
- Authorize WP2Astro in Vercel popup
- Instant setup, easiest method
Option B: Use Vercel Token
- Get token from vercel.com/account/tokens
- Click "Create Token"
- Name it "WP2Astro"
- Copy the token
- Paste into WP2Astro modal
- Click "Connect"
Step 2: Setup Project Deployment
Once Vercel is connected:
- Find your project card on the dashboard
- Click "Setup Deployment" button
- A modal opens showing your project details
- Click "Deploy to Vercel"
What Happens Next
WP2Astro automatically:
✓ Creates Vercel project
✓ Links GitHub repository
✓ Configures build settings
✓ Triggers initial build
✓ Deploys to global CDN
✓ Provides deployment URL
Deployment complete! 🎉
This takes about 2-3 minutes.
[screenshot of deployment status]
Deployment Status
Monitoring Deployments
Your project card shows real-time status:
Building 🟡
- Vercel is compiling your site
- Installing dependencies
- Running
npm run build - Optimizing assets
Live ✅
- Successfully deployed
- Site is accessible
- Click "View Site" to open
- URL:
https://your-project.vercel.app
Failed ❌
- Build encountered an error
- Check logs in Vercel dashboard
- Fix the issue and redeploy
[screenshot of deployment status]
Refresh Status
If status seems stuck:
- Click the refresh icon ⟳ on your project card
- Status updates immediately
- Fetches latest deployment info from Vercel
Automatic Deployments
After initial setup, deployments happen automatically.
How Auto-Deploy Works
1. You edit a file in WP2Astro IDE
↓
2. File auto-saves (500ms after typing)
↓
3. WP2Astro commits change to GitHub
↓
4. GitHub webhook notifies Vercel
↓
5. Vercel pulls latest code
↓
6. Build runs in Vercel cloud
↓
7. New version deployed to CDN
↓
8. Site updated (~2 minutes total)
Timeline
- Save: Instant (auto-save)
- Commit: 1-2 seconds
- Build trigger: 5-10 seconds
- Build time: 1-2 minutes
- Deploy: 10-20 seconds
- Total: ~2-3 minutes from save to live
What Triggers Deployment
Deployments are triggered by:
- Saving files in the IDE
- Pushing commits via terminal
- Merging pull requests
- Manual deploy from Vercel dashboard
Build Configuration
Vercel automatically detects Astro projects and configures everything:
Auto-Detected Settings
Framework: Astro
Build Command: npm run build
Output Directory: dist
Install Command: npm install
Node.js Version: 20.xYou don't need to configure anything - it just works!
Custom Build Settings (Advanced)
If you need to customize, create vercel.json:
{
"buildCommand": "npm run build",
"outputDirectory": "dist",
"devCommand": "npm run dev",
"installCommand": "npm install",
"framework": "astro"
}Environment Variables
Add secrets via Vercel dashboard:
- Go to Project Settings in Vercel
- Click "Environment Variables"
- Add variables:
SITE_URL=https://yoursite.com
PUBLIC_API_URL=https://api.yoursite.com
ANALYTICS_ID=G-XXXXXXXXXX
Access in your code:
const siteUrl = import.meta.env.SITE_URL;
const apiUrl = import.meta.env.PUBLIC_API_URL;Understanding the Deployment
What Gets Deployed
When Vercel builds your site:
Source (GitHub) → Build Process → Production (CDN)
src/pages/ → npm run build → dist/index.html
src/components/ → npm run build → dist/about/index.html
src/styles/ → npm run build → dist/_astro/styles.css
public/images/ → copy static → dist/images/
Build Output
Vercel generates:
dist/
index.html # Homepage
about/
index.html # About page
blog/
post-1/
index.html
post-2/
index.html
_astro/
styles.[hash].css # Minified CSS
scripts.[hash].js # Minified JS
images/ # Optimized images
Optimizations Applied
Vercel automatically:
- Compresses all assets (Gzip/Brotli)
- Optimizes images (WebP, AVIF)
- Minifies CSS and JavaScript
- Generates source maps
- Creates service worker (if configured)
- Sets cache headers
Custom Domains
Adding Your Domain
- Go to Vercel dashboard
- Select your project
- Go to Settings → Domains
- Click "Add Domain"
- Enter your domain (e.g.,
yoursite.com)
DNS Configuration
For apex domain (yoursite.com):
Type: A
Name: @
Value: 76.76.21.21
For www subdomain:
Type: CNAME
Name: www
Value: cname.vercel-dns.com
SSL Certificate
Vercel automatically:
- Provisions SSL certificate
- Renews before expiration
- Redirects HTTP to HTTPS
- Supports custom certificates
No configuration needed! SSL just works.
Deployment URLs
Default URL
Every project gets a free Vercel URL:
https://your-project.vercel.app
https://your-project-username.vercel.app
Preview URLs
Every deployment gets unique URL:
https://your-project-[hash].vercel.app
https://your-project-git-[branch].vercel.app
Use preview URLs to:
- Test before going live
- Share with clients
- QA different branches
Production URL
Your main deployment URL:
https://your-project.vercel.app
https://yoursite.com (if custom domain)
Always points to latest successful deployment.
Deployment Logs
Viewing Build Logs
From Vercel dashboard:
- Go to your project
- Click "Deployments" tab
- Click specific deployment
- View detailed logs
Log Contents
[12:34:56] Installing dependencies...
[12:35:12] npm install completed
[12:35:13] Running build command...
[12:35:14] > astro build
[12:35:15] Building for production...
[12:36:42] Build completed
[12:36:43] Deploying to CDN...
[12:36:55] Deployment complete!Debug Build Issues
Common errors and solutions:
Module Not Found:
Error: Cannot find module 'package-name'
Fix: npm install package-nameBuild Timeout:
Error: Build exceeded maximum duration
Fix: Optimize build, upgrade planOut of Memory:
Error: JavaScript heap out of memory
Fix: Reduce build size, upgrade planPerformance
Global CDN
Your site is deployed to Vercel's edge network:
- 100+ locations worldwide
- Automatic routing to nearest server
- DDoS protection included
- 99.99% uptime SLA
Speed Metrics
Typical performance for Astro + Vercel:
- TTFB: < 50ms (Time To First Byte)
- FCP: < 1s (First Contentful Paint)
- LCP: < 1.5s (Largest Contentful Paint)
- TTI: < 2s (Time To Interactive)
Lighthouse Scores: Often 95-100 across all metrics
Caching Strategy
Vercel automatically sets optimal cache headers:
Static Assets: Cache-Control: public, max-age=31536000, immutable
HTML Pages: Cache-Control: public, max-age=0, must-revalidate
API Routes: Custom per-route configuration
Free Tier Limits
Vercel's Hobby (free) plan includes:
Bandwidth:
- 100 GB per month
- Enough for 100,000+ page views
Build Time:
- 100 hours per month
- ~6,000 builds
- 1 minute average build = plenty of headroom
Deployments:
- Unlimited deployments
- Unlimited preview deployments
Projects:
- Unlimited projects
Team Members:
- Solo developer (1 member)
Perfect for:
- Personal blogs
- Portfolio sites
- Side projects
- Small business sites
When to Upgrade
Consider Pro plan ($20/month) if you need:
- Commercial projects
- Team collaboration
- More bandwidth (1 TB)
- Faster builds
- Priority support
- Analytics
- Password protection
Rollback and Revert
Instant Rollback
Made a mistake? Rollback instantly:
- Go to Vercel dashboard
- Click "Deployments"
- Find previous working deployment
- Click "Promote to Production"
- Previous version goes live immediately
How Rollback Works
Current: Deployment #45 (broken)
↓ Rollback
Previous: Deployment #44 (working)
↓ Promoted
Production: Now serving #44
No rebuild needed - previous version is cached.
Preview Deployments
Every Commit Gets a Preview
When you push to a branch:
1. Push to feature-branch
↓
2. Vercel detects push
↓
3. Builds feature-branch
↓
4. Creates preview URL
↓
5. Comment on GitHub (if PR exists)
Preview URLs
https://your-project-git-feature-branch.vercel.app
Use for:
- Testing new features
- Client review
- QA before merge
- Sharing with team
Disconnecting Vercel
Need to disconnect? From WP2Astro dashboard:
- Go to sidebar
- Find "Deploy to Vercel" section
- Click "Disconnect Vercel"
- Confirm disconnection
What happens:
- Vercel token removed from WP2Astro
- Project stays live on Vercel
- Deployments stop from WP2Astro
- Can reconnect anytime
Note: Your site continues running on Vercel. This only removes the WP2Astro connection.
Troubleshooting
Deployment Fails
Check build logs:
- Go to Vercel dashboard
- View deployment details
- Look for error message
- Fix the issue
- Retry deployment
Common issues:
- Missing dependencies in package.json
- TypeScript errors
- Build script errors
- Environment variables not set
Site Not Updating
Possible causes:
- Build failed - Check Vercel dashboard
- Browser cache - Hard refresh (Cmd+Shift+R)
- CDN cache - Wait 1-2 minutes
- Not deployed - Check deployment status
Solutions:
- Clear browser cache
- Check deployment succeeded
- Verify changes committed to GitHub
- Check Vercel isn't paused
Wrong Version Deployed
If wrong version is live:
- Check which commit is deployed (Vercel dashboard)
- Verify correct code is on main branch
- Trigger manual deploy from Vercel
- Check deployment logs
Connection Issues
If can't connect Vercel:
- Verify Vercel token is valid
- Check Vercel account isn't suspended
- Try disconnecting and reconnecting
- Generate new token and try again
Best Practices
Deployment Workflow
Development:
Work in IDE → Auto-save → Auto-commit → Auto-deploy
See changes live in 2-3 minutes
For larger changes:
Create feature branch → Make changes → Test preview
Merge to main → Production deploy
Testing Before Deploy
Local preview (optional):
# In IDE terminal
npm run build
npm run previewUse preview deployments:
- Work on branches
- Get preview URLs
- Test thoroughly
- Merge when ready
Performance Monitoring
Use Vercel Analytics:
- See real user metrics
- Track Core Web Vitals
- Monitor performance
- Get insights
External tools:
- Google PageSpeed Insights
- GTmetrix
- WebPageTest
Advanced Features
Edge Functions
Add server-side functionality:
// api/hello.js
export default function handler(request) {
return new Response(JSON.stringify({
message: 'Hello from the edge!'
}), {
headers: { 'content-type': 'application/json' }
});
}Redirects
Configure in vercel.json:
{
"redirects": [
{
"source": "/old-blog/:slug",
"destination": "/blog/:slug",
"permanent": true
}
]
}Headers
Custom HTTP headers:
{
"headers": [
{
"source": "/(.*)",
"headers": [
{
"key": "X-Frame-Options",
"value": "DENY"
}
]
}
]
}Comparison: Vercel vs Others
Why Not Netlify or Cloudflare?
WP2Astro currently only supports Vercel because:
- Tight integration: Built specifically for WP2Astro
- Automatic setup: Zero configuration needed
- Best performance: Optimized for Astro
- Reliability: 99.99% uptime
Other platforms coming soon! We're working on:
- Netlify integration
- Cloudflare Pages support
- Self-hosted options
For now, Vercel provides the best experience with WP2Astro.
Next Steps
Now that your site is deployed:
- Add a custom domain
- Set up analytics
- Configure environment variables
- Learn about performance optimization