Back to Blog
Tutorial8 min read2026-06-27

How to Deploy an Astro Site for Free

Astro builds blazing-fast static sites by default. Learn how to build for production, when you need an adapter, and how to deploy your Astro site to the edge for free.

Ajay Kumar
Ajay Kumar
Founder & DevOps, PandaStack

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 ./dist

That'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 modeArtifactHosting
static (default)dist/ filesAny static host / CDN
serverNode/edge server via adapterContainer or serverless
hybrid (mixed)Static + on-demand routesServer-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 prefetch for 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:

  1. 1Connect your Git repository as a static site.
  2. 2PandaStack auto-detects Astro, runs npm run build, and serves dist/ over the global edge.
  3. 3Add your custom domain — automatic SSL is issued for you.
  4. 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.

SettingValue
FrameworkAstro (auto-detected)
Build commandnpm run build
Output dirdist
TLSAutomatic SSL
CostFree 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, not build; 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

Ready to deploy?

Start free on PandaStack.

Start free on PandaStack

More in Tutorial

Browse all Tutorial articles →

See also