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.
- 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
| Mode | How pages are built | Best for | Adapter needed? |
|---|---|---|---|
Pure static (output: "static") | All HTML built at deploy time, served straight from CDN | Marketing sites, blogs, docs, catalogues | No |
Static + opt-in SSR (prerender = false) | Marketing pages are static; specific routes run on the server per request | Sites 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 = true | Dashboards, personalised apps, huge live inventories | Yes |
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:
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.
Related articles
- DeployingDeploy an Astro site to Cloudflare WorkersA static Astro site needs no adapter: a four-line wrangler.jsonc and wrangler deploy. When pages render on request, add @astrojs/cloudflare. Both tested.
- DeployingCloudflare Workers custom domain not working: DNS and SSL fixesFix Cloudflare Workers custom domain errors: conflicting A/CNAME records, ERR_TOO_MANY_REDIRECTS with Flexible SSL, pending CAA validation and apex redirects.
- Using themes.devFrom website template to live site, step by stepGet the theme from GitHub or as a zip, run it locally, replace the demo content, set SITE_URL and deploy to Cloudflare, Netlify or Vercel.
Still stuck? We answer every message ourselves. Write to us