komal.nakrani
Browse Themes
ThemesCategoriesDocsBlogTips & Tricks
Server Rendering••By Komal Nakrani

Static or SSR? Which Rendering Mode Your Astro Page Needs

Astro static or SSR? Answer five questions per page: does content differ per visitor, change faster than a rebuild, or need one dynamic part? Then pick the mode.

#Astro#Decision Guide#SSR#Static

Choosing between Astro static or SSR rendering is a per-page decision, not a per-site one. Prerender (static) any page whose content is the same for every visitor and can wait for a rebuild. Render on demand only pages that read cookies or headers, or that must show data fresher than your last build. If just one component on a page is personal, keep the page static and make that component a server island. Most Astro sites end up 95% static.

Key Takeaways

  • Default to static: it’s the fastest, cheapest and least fragile option.
  • Use on-demand rendering for per-visitor content and data that changes faster than you can rebuild.
  • Use a server island when only one part of a page is dynamic.
  • Client-side fetching suits small public data on static pages.

The decision in five questions

Ask these for each page, in order. Stop at the first “yes”.

  1. Does the page show different content to different visitors? (logged-in state, cart, personal data)
    • Only one component does → server island.
    • Most of the page does → on-demand.
  2. Must the data be fresher than your rebuild time? (stock, prices, live scores)
    • Small, public data → static + client-side fetch.
    • Core content of the page → on-demand with short CDN caching.
  3. Does the page handle a form submission with a full-page response? → on-demand (or a static page calling an action from a script).
  4. Is the URL space unknown at build time? (search results, arbitrary IDs) → on-demand.
  5. None of the above? → static.

The options side by side

Mode How Needs adapter Cached at CDN Best for
Static Default No Yes, fully Marketing pages, blogs, docs, product pages
Static + client fetch <script> or island calling an API No Page yes, data per API Small live bits: stock count, latest release
Static + server island server:defer on one component Yes Page yes, island optionally Avatar, cart count, personalised block
On-demand export const prerender = false Yes With Cache-Control Account pages, dashboards, search, auth
Mostly on-demand output: 'server' + prerender = true on static pages Yes Per page App-like sites with a few static pages

Examples

Page Mode Why
Home page Static Same for everyone
Blog post Static Rebuild on publish is fast enough
Product page with live stock Static + server island or client fetch Only the stock line changes
Pricing page with a currency switcher Static Switch in the browser
Account settings On-demand Per-user data behind a login
Search results On-demand Unknown queries
Contact form with thank-you page Static + action from script, or on-demand Depends on JS preference
Docs Static Content changes with deploys

What each choice costs

Static pages are files on a CDN. First byte is fast everywhere, there’s nothing to crash, and hosting is often free. The cost is staleness: content updates need a rebuild, which a CMS webhook can trigger.

On-demand pages run code per request. You get fresh data and access to cookies, but you pay in hosting (functions or a server), cold starts on some platforms, slower first bytes than a CDN file, and more ways to fail. Caching headers recover much of the speed for public pages.

Server islands split the difference: a static, cacheable page with one component fetched per request after load.

Setting it up

// astro.config.mjs: keep the default static output, add an adapter
import node from '@astrojs/node';
export default defineConfig({ adapter: node({ mode: 'standalone' }) });
---
// src/pages/account.astro
export const prerender = false;
---

The full mechanics are in mixing static and on-demand pages and the Astro SSR guide. Hosting differences are in the Astro deploy guide.

Static by default

Komal themes are fully static Astro 7 sites, so every page starts on the fastest option. Add an adapter only when a page needs it. Browse Astro themes.

FAQ

Is SSR better for SEO than static in Astro?

No. Both send complete HTML to crawlers. Static pages are usually faster, which helps.

Can I switch a page between static and SSR later?

Yes. Add or remove export const prerender = false. Dynamic routes need getStaticPaths() when static.

The official explanation of each mode is in the on-demand rendering docs.