Back to blog
guide · 5 min read

Static vs SSR in Astro: When to Use What

E
Eastvale Team

One of Astro’s strengths is flexibility. You can statically generate some pages and server-render others — in the same project. But when should you use which?

Static Generation (Default)

By default, Astro pre-renders every page at build time. The result is plain HTML files served from a CDN. This is ideal for:

  • Marketing pages
  • Blog posts
  • Documentation
  • Portfolios
  • Any content that doesn’t change per-request

Server-Side Rendering

When you need dynamic, per-request content, enable SSR for specific pages:

---
export const prerender = false;

const user = await getUser(Astro.cookies.get('session'));
---
<Dashboard user={user} />

Use SSR for:

  • User dashboards
  • Authenticated content
  • Search results
  • Real-time data
  • A/B testing

The Hybrid Approach

Astro’s hybrid mode lets you mix both. Your marketing pages are statically generated for speed. Your dashboard pages are server-rendered for freshness. One project, one deployment.

// astro.config.mjs
export default defineConfig({
  output: "hybrid", // static by default, opt-in to SSR
});

Our Rule of Thumb

Start static. If a page needs to be different for every request, make it server-rendered. If it changes daily, use static with a rebuild trigger. If it changes every minute, use SSR with caching.

We walk through all of these patterns in Module 3 of the course.