Skip to content

Deploying Astro — Vercel, Netlify, Cloudflare, and More

Hermes Team · · 2 min read

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

PlatformFree TierBuild TimeBest For
VercelYes100 min/moFull-stack, previews
NetlifyYes300 min/moForms, content
CloudflareYesUnlimitedPerformance, cost
GitHub PagesYes2000 min/moOSS, docs

Pick based on your needs. For most Astro sites, any of these will work beautifully.