Skip to content

Astro static vs SSR: when to use prerender or an adapter

Compare static output, per-route prerender = false, and full server mode in Astro: when you actually need an adapter, CDN TTFB, and Cloudflare Workers.

Updated 3 December 2026Tested with
  • Astro 7.4.13
  • @astrojs/cloudflare 14.4.9

In Astro 5+, output: "static" is the default and already supports mixing prerendered pages with on-demand server routes in the same project. You do not need to switch your whole site to output: "server" just to add a contact form, an API endpoint, or an account page.

Static vs on-demand (SSR) at a glance

ModeHow pages are builtBest forAdapter needed?
Pure static (output: "static")All HTML built at deploy time, served straight from CDNMarketing sites, blogs, docs, cataloguesNo
Static + opt-in SSR (prerender = false)Marketing pages are static; specific routes run on the server per requestSites with a few dynamic routes (checkout, API, auth)Yes (e.g. @astrojs/cloudflare)
Full server (output: "server")Every request renders HTML on the server unless opted into prerender = trueDashboards, personalised apps, huge live inventoriesYes

The recommended default: static with opt-in SSR

Keep output: "static" in astro.config.mjs so every public page gets instant CDN TTFB, and add one line at the top of only the routes that need live request data:

src/pages/api/contact.tsTypeScript
export const prerender = false; import type { APIRoute } from "astro"; export const POST: APIRoute = async ({ request }) => {  const data = await request.formData();  // validate and handle submission  return new Response(JSON.stringify({ ok: true }), {    headers: { "Content-Type": "application/json" },  });};

Questions

What happened to output: "hybrid" in Astro?

Astro merged hybrid into the default static mode. In modern Astro, output: "static" already allows export const prerender = false on any route as soon as an adapter is installed.

Can I deploy a static Astro site to Cloudflare Workers?

Yes — with a four-line wrangler.jsonc and no adapter at all. See Deploy an Astro site to Cloudflare Workers.

Was this page helpful?

Still stuck? We answer every message ourselves. Write to us

Building with shadcn/ui and Tailwind CSS v4?

Install 188 free blocks and components with the shadcn CLI (no account), preview them in your own brand in Studio, or get all 1,570 blocks and every theme in UI Pro (€199 once).

Use it with

This page is built from UI Pro parts: the docs article block (docs-quernly) with the code, terminal, install command, steps, contents and feedback components, included in UI Pro.