Deploying Astro — Vercel, Netlify, Cloudflare, and More
Astro outputs static files by default. That means you can deploy anywhere. Here’s a rundown of the most popular options and how to get started.
Vercel
Best for: Teams already using Next.js, automatic previews
npm i -g vercel
vercel
Vercel detects Astro automatically. Connect your repo for automatic deployments on push. Preview deployments for every PR. Free tier is generous.
Pros: Zero config, great DX, edge functions if needed
Cons: Can get expensive at scale
Netlify
Best for: Content sites, form handling, split testing
npm i -g netlify-cli
netlify deploy
Netlify also auto-detects Astro. Build command: npm run build. Publish directory: dist. Add form handling, serverless functions, or redirects via netlify.toml.
Pros: Forms, identity, split testing, easy config
Cons: Build minutes can be limited on free tier
Cloudflare Pages
Best for: Global performance, cost-conscious
Connect your Git repo and Cloudflare builds on every push. Or use Wrangler for CLI:
npm run build
npx wrangler pages deploy dist
Pros: Unlimited bandwidth, fast global CDN, free
Cons: Build environment is different from Node—some packages may need adjustment
GitHub Pages
Best for: Open source, documentation, personal sites
Use the gh-pages branch or GitHub Actions:
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./dist
Pros: Free, integrated with GitHub
Cons: No serverless, no custom domains on free (unless using GitHub Pages)
Other Options
- AWS Amplify — Full CI/CD, good for AWS-heavy teams
- Firebase Hosting — Simple, integrates with Firebase services
- Render — Static sites, free tier
- Railway — Flexible, supports static + dynamic
Environment Variables
All platforms support environment variables. Set them in the dashboard or via CLI. For Astro, import.meta.env.PUBLIC_* exposes variables to the client.
Custom Domains
Every platform supports custom domains. Add a CNAME record pointing to their URL. Most offer free SSL via Let’s Encrypt.
Summary
| Platform | Free Tier | Build Time | Best For |
|---|---|---|---|
| Vercel | Yes | 100 min/mo | Full-stack, previews |
| Netlify | Yes | 300 min/mo | Forms, content |
| Cloudflare | Yes | Unlimited | Performance, cost |
| GitHub Pages | Yes | 2000 min/mo | OSS, docs |
Pick based on your needs. For most Astro sites, any of these will work beautifully.