Deployment Methods
You can deploy your Astro site to Vercel using any of these methods:Prerequisites
Before deploying, make sure you have:
- A Vercel account (free tier available)
- Your project pushed to a Git repository (GitHub, GitLab, or Bitbucket)
- The Vercel CLI installed (optional, for CLI deployment)
If you don’t have a Git repository yet, initialize one and push your code:
Deploy via Vercel Dashboard
The easiest way to deploy is through the Vercel dashboard:
- Go to vercel.com/new
- Import your Git repository
- Vercel will automatically detect your Astro project
- Click Deploy
Deploy via Vercel CLI
For more control, use the Vercel CLI:The CLI will guide you through the setup process, including linking your project to a Vercel project.
Configure environment variables (if needed)
If your project requires environment variables, add them in the Vercel dashboard:You can also set environment variables using the CLI:
- Go to your project settings
- Navigate to Environment Variables
- Add your variables for Production, Preview, and Development environments
The boilerplate doesn’t require environment variables by default, but you may need them for:
- API keys
- Database connections
- Third-party service credentials
Verify deployment
After deployment completes, Vercel will provide you with:
- A production URL (e.g.,
your-project.vercel.app) - A preview URL for each Git branch
- Automatic HTTPS certificates
- Your homepage displaying IP address and city information
- All demo pages functioning correctly
- Vercel Analytics enabled (check the dashboard)
Each Git push to your main branch will trigger a new production deployment automatically. Pushes to other branches create preview deployments.
Astro Configuration for Vercel
The boilerplate is pre-configured with optimal Vercel settings inastro.config.mjs:
astro.config.mjs
Key Configuration Options
output: 'server' - Enables server-side rendering by default. Pages can opt into static pre-rendering using export const prerender = true.edgeMiddleware: true - Runs middleware on Vercel Edge Functions for ultra-low latency request processing.imageService: true - Enables Vercel Image Optimization for automatic image resizing and format conversion.webAnalytics.enabled: true - Automatically enables Vercel Web Analytics for your site.isr.expiration - Sets the cache duration for ISR pages. In this config, pages are cached for 24 hours.ISR Configuration
Incremental Static Regeneration (ISR) is enabled with these settings:Image Optimization
The boilerplate uses Vercel’s Image Optimization service with these settings:/image page:
src/pages/image.astro
Monitoring Your Deployment
Once deployed, you can monitor your site using:- Vercel Analytics - Track page views, visitor metrics, and top pages
- Speed Insights - Monitor Core Web Vitals and performance scores
- Deployment logs - View build logs and runtime errors
- Function logs - Debug edge functions and serverless functions
Continuous Deployment
Vercel automatically sets up continuous deployment:- Production deployments - Triggered on pushes to your main/master branch
- Preview deployments - Created for every pull request and branch push
- Automatic rollbacks - Instantly rollback to previous deployments if needed
Custom Domains
To add a custom domain:- Go to your project settings in Vercel
- Navigate to Domains
- Add your custom domain
- Configure DNS records as instructed
Troubleshooting
Build Failures
If your build fails:- Check the build logs in the Vercel dashboard
- Ensure all dependencies are listed in
package.json - Verify your
astro.config.mjsis valid - Run
npm run buildlocally to reproduce the error
Runtime Errors
If you encounter runtime errors:- Check the Function logs in Vercel
- Ensure environment variables are set correctly
- Verify edge function compatibility (some Node.js APIs are not available on the edge)
Next Steps
Vercel Documentation
Learn more about Astro on Vercel
Astro Vercel Adapter
Deep dive into the Vercel adapter