Astro is built around a simple, powerful idea: ship zero JavaScript by default and only hydrate the interactive bits ("islands"). For most content sites, that means a fully static build that's astonishingly fast — and perfect for free static hosting. Here's how to deploy one.
Static by default
Out of the box, astro build produces a dist/ folder of pre-rendered HTML, CSS, and minimal JS. No server, no runtime — just files you can serve from any CDN or static host.
npm run build
# outputs to ./distThat's the whole production artifact for a static site. Because there's no server, hosting is cheap (or free) and scales effortlessly.
When do you need an adapter?
Astro only needs an adapter when you opt into on-demand rendering (SSR) — for example, server-rendered pages, API endpoints, or per-request logic. You set this with output: 'server' or by marking specific routes with export const prerender = false.
| Output mode | Artifact | Hosting |
|---|---|---|
static (default) | dist/ files | Any static host / CDN |
server | Node/edge server via adapter | Container or serverless |
hybrid (mixed) | Static + on-demand routes | Server-capable host |
For a blog, docs, or marketing site, stay static — it's simpler, faster, and free to host. Only reach for an adapter when you genuinely need server-side behavior.
Configuring the static build
Make sure your astro.config.mjs sets your production site URL so canonical links, sitemaps, and RSS generate correctly:
import { defineConfig } from 'astro/config';
export default defineConfig({
site: 'https://example.com',
build: {
inlineStylesheets: 'auto',
},
});The site value feeds the sitemap and RSS integrations — a frequently forgotten step that breaks SEO metadata.
Optimizing the build
A few production wins:
- Image optimization — use Astro's
component (astro:assets) so images are resized and served in modern formats. - Content collections — type-safe Markdown/MDX with schema validation, great for blogs and docs.
- Prefetching — enable
prefetchfor near-instant navigation between pages.
export default defineConfig({
prefetch: true,
});Deploying on PandaStack (free)
A static Astro site is an ideal fit for free hosting. On PandaStack:
- 1Connect your Git repository as a static site.
- 2PandaStack auto-detects Astro, runs
npm run build, and servesdist/over the global edge. - 3Add your custom domain — automatic SSL is issued for you.
- 4Push to your branch — it rebuilds and redeploys with live build logs.
Static builds run in fast microVMs, and the free tier includes 5 static sites (Pro and above are unlimited) with 100 GB/month bandwidth. No server to manage, no scaling to think about.
| Setting | Value |
|---|---|
| Framework | Astro (auto-detected) |
| Build command | npm run build |
| Output dir | dist |
| TLS | Automatic SSL |
| Cost | Free tier |
Common pitfalls
- Forgetting to set
site— broken canonical URLs and sitemaps. - Adding an adapter you don't need — needless complexity; stay static unless you require SSR.
- Not using
astro:assets— unoptimized images bloat the page. - Wrong output directory — Astro outputs to
dist, notbuild; configure your host accordingly.
References
- Astro deployment overview: https://docs.astro.build/en/guides/deploy/
- Astro on-demand rendering (SSR): https://docs.astro.build/en/guides/on-demand-rendering/
- Astro adapters: https://docs.astro.build/en/guides/server-side-rendering/
- Astro image optimization: https://docs.astro.build/en/guides/images/
- Astro configuration reference: https://docs.astro.build/en/reference/configuration-reference/
---
A static Astro site costs nothing to host on PandaStack's free tier — connect your repo, get automatic SSL on your custom domain, and edge-served pages. Deploy at https://dashboard.pandastack.io