Deployment
The template ships as a fully static site (output: "static" is the Astro default). The pnpm build command produces a dist/ directory that you can drop on any static host with zero server-side requirements.
Before you deploy
Section titled “Before you deploy”# 1. Verify there are no TypeScript errorspnpm build
# 2. Preview the production build locallypnpm previewpnpm build runs astro check (type-checking) then astro build. Fix any errors before pushing.
Vercel
Section titled “Vercel”The fastest path. Connect your GitHub repository in the Vercel dashboard and Vercel detects Astro automatically.
Manual deploy (CLI):
npm install -g vercel # install oncevercel # first deploy — follow the promptsvercel --prod # subsequent production deploysSettings to confirm in Vercel dashboard:
| Setting | Value |
|---|---|
| Framework Preset | Astro |
| Build Command | pnpm build |
| Output Directory | dist |
| Node.js Version | 20.x |
Environment variables: Vercel → Project → Settings → Environment Variables. Add any STRAPI_URL, DIRECTUS_URL, etc. here — never commit them to the repo.
Netlify
Section titled “Netlify”Via Netlify UI:
- Connect your repository.
- Set Build command:
pnpm build - Set Publish directory:
dist - Set environment variable
NODE_VERSIONto20.
Via netlify.toml (add to project root):
[build] command = "pnpm build" publish = "dist"
[build.environment] NODE_VERSION = "20"Deploy hooks: In Netlify → Site settings → Build & deploy → Build hooks, create a hook URL. Paste it in your CMS webhook settings to trigger rebuilds on content publish.
Cloudflare Pages
Section titled “Cloudflare Pages”- Log into Cloudflare Dashboard → Pages → Create a project.
- Connect your Git provider and select the repository.
- Set:
| Setting | Value |
|---|---|
| Framework preset | Astro |
| Build command | pnpm build |
| Build output directory | dist |
| Environment variable | NODE_VERSION = 20 |
- Click Save and Deploy.
Cloudflare’s global CDN means excellent Lighthouse scores with minimal config.
Self-hosted / static host
Section titled “Self-hosted / static host”Any host that serves static files works (nginx, Apache, AWS S3 + CloudFront, Bunny CDN, etc.):
pnpm build# Upload the dist/ directory to your hostnginx example config:
server { listen 80; root /var/www/my-site/dist; index index.html;
# SPA-style fallback for Astro's file-based routing location / { try_files $uri $uri/ $uri.html =404; }}Adding SSR (server-side rendering)
Section titled “Adding SSR (server-side rendering)”The template is static by default. To enable SSR (required for form submissions, auth, or on-demand CMS revalidation):
- Install an adapter:
# Vercelpnpm add @astrojs/vercel
# Netlifypnpm add @astrojs/netlify
# Cloudflarepnpm add @astrojs/cloudflare- Update
astro.config.mjs:
import vercel from "@astrojs/vercel/serverless";
export default defineConfig({ output: "server", adapter: vercel(),});- Pages that should remain static can opt out individually:
export const prerender = true;Environment variables
Section titled “Environment variables”Variables prefixed with PUBLIC_ are exposed to the client. All others are server-only:
# .env.local (never commit this file)STRAPI_API_TOKEN=abc123 # server-onlyPUBLIC_PLAUSIBLE_DOMAIN=you.com # exposed to clientAdd the same variables in your hosting provider’s dashboard for production. The .env.local file is already in .gitignore.