Astro
Astro SSR and Hybrid Rendering
Written by Noel
Published:
20 min read
Topics researched with AI assistance; reviewed and edited by Noel before publishing.

Explore this topic
More Astro guides, glossary entries, and practical workflows live on the topic hub.
Astro SSR hybrid rendering is a way to combine static pages and server-rendered pages in the same Astro project. It matters because not every page has the same needs: a marketing page can stay static, while an account page, inventory page, or personalized dashboard may need fresh data at request time.
For merchants and developers, the practical value is simple: keep the fast, low-maintenance parts static, and use server rendering only where the business case justifies it. That balance is what makes hybrid rendering useful in real projects.
Key takeaways
- Static should remain the default unless a route truly depends on request-time data.
- SSR in Astro is route-level, so you can keep most of the site static and only render specific pages on demand.
- An adapter is required for server-rendered routes because Astro needs a runtime to execute them.
- Hybrid rendering is strongest when freshness, personalization, or cookies matter more than build-time simplicity.
- The main failure mode is overusing SSR and turning a simple site into a harder-to-cache application.
What is it?
Astro SSR hybrid rendering means using two rendering modes together: prerendered static output for some routes and server-side rendering for others. In Astro, the default is static generation, but you can opt specific pages or endpoints out of prerendering when they need to run on the server at request time.
A concrete example helps. Imagine an ecommerce site with a homepage, collection pages, and editorial content. Those pages can usually be prerendered because they do not need to change for each visitor. But the account page may need to show the logged-in user’s order history, and a stock-sensitive page may need to show fresh availability. In that setup, the site is hybrid: most routes stay static, while a few routes are rendered on demand.
This is different from treating SSR as the default for everything. Hybrid rendering is selective. It gives you a way to keep the performance and simplicity of static pages while still supporting features that only make sense when the server is involved. That is why it is often a better fit than an all-SSR approach for content-heavy sites, catalogs, and merchant-facing storefronts.
The term also matters for planning. Once a team understands that Astro can mix rendering modes, they can design routes more deliberately. Instead of asking, “Should the whole site be static or dynamic?” the better question becomes, “Which routes actually need server execution, and why?” That shift usually leads to cleaner architecture and fewer unnecessary runtime dependencies.
A useful way to think about it is that Astro gives you a spectrum rather than a single switch. At one end are fully prerendered pages that are built once and served many times. At the other end are routes that render on demand for each request. Hybrid rendering sits in the middle and lets you choose per route. That is especially valuable when a site has a stable public layer and a smaller application-like layer.
In practical terms, this also changes how teams talk about “dynamic” pages. A route can be dynamic because it reads cookies, because it fetches fresh data, because it needs redirects, or because it must personalize content. Those are related but not identical needs. Astro SSR hybrid rendering gives you a way to match the route to the exact kind of dynamism it requires instead of assuming every non-static page needs the same architecture.
Why it matters
The business case for astro ssr hybrid rendering is about matching rendering cost to business value. A static page is cheap to serve, easy to cache, and usually fast for users. A server-rendered page can be more flexible, but it also introduces runtime complexity. Hybrid rendering lets you spend that complexity only where it pays off.
For merchants, the biggest impact is often freshness and personalization. If a customer logs in, checks an account page, or views data that changes frequently, static HTML may be stale or incomplete. SSR can show the current state without waiting for a full rebuild. That is especially useful when the page needs to reflect cookies, session state, or recently updated records.
For developers, hybrid rendering can make a project easier to maintain than a fully dynamic setup. You do not have to move every route into server logic just because one or two routes need it. You can preserve static builds for the majority of the site, which keeps deployment simpler and reduces the surface area for bugs.
There is also a performance angle. Static pages are still the best option for many routes because they ship immediately and can be cached aggressively. If you force SSR everywhere, you may make the entire site depend on runtime availability and request latency. A hybrid model avoids that trap by keeping the fast path fast.
The technical impact is just as important. Once a route renders on demand, it can access request-time data, cookies, and response headers. That unlocks features such as user-specific content, conditional redirects, and data that should not be baked into a build artifact. But it also means you need to think about adapter choice, deployment runtime, and whether a route should be cached or not.
In practice, this matters most when teams are trying to avoid false tradeoffs. A project does not have to choose between “simple but stale” and “fresh but slow.” Hybrid rendering gives you a third option: simple where possible, dynamic where necessary. That is often the most realistic architecture for merchant sites that need both marketing performance and application behavior.
It also helps teams control operational risk. If only a few routes depend on server execution, then only those routes need runtime monitoring, cache rules, and deployment validation. That narrower blast radius is valuable when a site supports revenue-critical pages. A static homepage can keep serving even if a dynamic account route has a temporary issue, which is much harder to guarantee in an all-SSR setup.
How it works
Astro starts from a static-first model. By default, pages, routes, and endpoints are prerendered at build time and shipped as static HTML. That is the baseline. Hybrid rendering begins when you decide that some routes should not be prerendered and should instead be rendered on demand by a server.
Step 1: choose a runtime through an adapter
To render on demand, Astro needs an adapter. The adapter connects your project to a runtime such as Node, Netlify, Vercel, or Cloudflare. In practice, this is what lets Astro generate output that can run when a request arrives. Without an adapter, you can still build static sites, but you cannot serve SSR routes in the same way.
Step 2: opt routes out of prerendering
Once the adapter is in place, you can mark a page or endpoint with export const prerender = false. That tells Astro not to generate that route at build time. Instead, the route is rendered when a visitor requests it. This is the simplest form of hybrid rendering: keep the site mostly static, and opt out only where needed.
Step 3: let the server handle request-time data
On-demand routes can use request-specific information. They can read cookies, set cookies, inspect response status, and return content that depends on the current request. That is what makes SSR useful for personalized pages or data that changes often. A page can show the current user’s account state, or an endpoint can return a fresh response without waiting for a rebuild.
Step 4: decide whether the whole project should default to server output
For highly dynamic apps, Astro also supports a server-first configuration where the project is configured to server-render pages by default. In that model, you can still choose to prerender selected routes that do not need server execution. This is the reverse of the static-first approach, and it can make sense when most of the site is dynamic.
Step 5: understand streaming and response behavior
Astro uses HTML streaming in on-demand rendering, which means the document can be sent in chunks as it is rendered. That helps users see content sooner, even when some parts of the page depend on data fetches. The server-rendered route can also control response status and headers, which is useful for cases like missing products, redirects, or custom caching behavior.
The key mechanism is not “SSR versus static” as a binary choice. It is route-level control, backed by an adapter and a runtime, with the ability to mix build-time output and request-time output in one codebase.
A second mechanism to understand is where the rendering decision lives. In Astro, the decision is made in the route file and in project configuration, not hidden inside a global framework setting. That makes hybrid rendering easier to audit. You can open a page and see whether it is intended to be static or dynamic. For larger teams, that visibility is a real advantage because it reduces guesswork during reviews and debugging.
Another practical detail is that the server-rendered route is still part of the same project structure as the static route. That means shared components, layouts, and content can be reused without duplicating the whole site. The rendering mode changes at the route boundary, not the entire codebase. This is one reason Astro hybrid rendering tends to feel lighter than moving a site into a full application framework.
Use cases
Hybrid rendering is most useful when a site has different classes of pages with different freshness requirements. A merchant site rarely needs every page to be dynamic, but it often has a few routes that are clearly better served on demand.
One common scenario is authenticated content. Account pages, order history, saved addresses, or member-only dashboards usually depend on cookies or session state. Those pages should not be frozen into static HTML because the content changes per visitor. SSR lets the page reflect the current user without a rebuild.
A second scenario is frequently changing business data. Product availability, inventory-sensitive pages, or operational dashboards may need to show the latest state. If the data changes often enough that build-time output becomes stale, on-demand rendering is a better fit. This is especially true when the page needs to respond to a specific request rather than a generic audience.
A third scenario is mixed-content sites. Many merchant sites combine editorial content, landing pages, and application-like features. The content pages can stay static, while a small part of the site uses SSR. That is a good fit for Astro because the framework is already designed to keep static and dynamic concerns separate.
There is also a useful product-launch scenario. A team may want a campaign page to remain static for speed, but a companion route may need to check a cookie, show region-specific pricing, or personalize a call to action. Hybrid rendering lets the campaign page stay lightweight while the companion route handles the logic that actually needs runtime access.
A fourth scenario is support or service pages that must reflect current state. For example, a shipping-status page may need to show whether an order has moved to a new stage, or a help-center route may need to route a user based on account status. Those are not always full application pages, but they do need request-time logic. Hybrid rendering keeps those routes separate from the rest of the site so the dynamic behavior does not leak everywhere.
In practice, hybrid rendering is less about “advanced architecture” and more about choosing the right rendering mode for each route. If a page is public, stable, and cache-friendly, static is usually enough. If a page depends on the visitor, the moment of the request, or server-only data, SSR becomes the better choice.
How to implement or apply it
The safest implementation pattern is to start static and add SSR only where a route proves it needs it. That keeps the project easy to reason about and avoids turning a mostly static site into a server-heavy application by default.
First, identify the routes that truly need request-time rendering. Good candidates include pages that read cookies, authenticated account pages, dynamic inventory pages, and endpoints that must return fresh data. If a route only changes occasionally, ask whether a rebuild, content sync, or cached static page would solve the problem more simply.
Second, add the adapter that matches your deployment environment. The adapter is not an optional detail; it is the piece that makes server rendering possible in Astro. If your deployment target is Netlify, Vercel, Cloudflare, or Node, choose the adapter that corresponds to that runtime and follow its configuration requirements.
Third, mark the route correctly. For a static-first project, use prerender = false on the page or endpoint that should render on demand. For a server-first project, you can configure the project to server output and then opt specific pages back into static output with prerender = true. The important part is consistency: teams should know which routes are static and which are server-rendered.
Fourth, think about data fetching and caching together. SSR solves freshness, but it does not automatically solve performance. If a route fetches data on every request, it may need caching, careful response headers, or a narrower scope of server logic. The goal is to use SSR where the request matters, not to recreate a full application server for every page.
Fifth, test the route as a request, not just as a build artifact. A static page can be validated by opening the generated HTML, but an SSR page should be checked under real request conditions. That means verifying cookie behavior, redirects, and any data that changes from one request to the next. Teams often miss bugs here because they only test the route in the browser after a build, not in the runtime that will actually serve it.
A practical decision rule helps here:
- Use static rendering when the page is public, stable, and the same for most visitors.
- Use SSR when the page depends on cookies, authentication, or fresh request-time data.
- Use hybrid rendering when the site has both kinds of pages and you want each route to use the lightest viable mode.
If you are unsure, start by rendering only the smallest number of routes on demand. That keeps the architecture easier to test and makes it simpler to expand later if more pages truly need server execution.
For teams that manage content and commerce together, it helps to write down a simple routing policy. For example: “Marketing pages are prerendered unless they need request-specific personalization; account and operational pages are server-rendered by default.” A short policy like that prevents accidental drift as the site grows.
A good implementation also includes a rollback path. If a route is moved to SSR and the team later finds that it does not need runtime execution, it should be easy to return it to static output. That flexibility is one of the main reasons hybrid rendering is worth adopting: it lets architecture evolve with the product instead of locking the team into one rendering choice forever.
Common mistakes and pitfalls
The most common mistake is using SSR because it sounds more flexible, not because the route needs it. That usually leads to unnecessary runtime dependencies and more complicated deployments. If a page can be static, it usually should be static.
Another mistake is forgetting that SSR requires an adapter. Teams sometimes write route logic as if the project will automatically run on a server, then discover that the deployment target is still configured for static output. In Astro, the adapter is part of the rendering decision, not a separate afterthought.
A third pitfall is mixing up freshness with personalization. A page that needs fresh data does not always need full SSR, and a page that needs personalization may need more than just a data fetch. The correct rendering mode depends on whether the route must react to the request itself, not just whether the content changes over time.
There is also a maintenance risk when route behavior is not documented. In a hybrid project, some pages are build-time assets and others are request-time responses. If the team does not keep that distinction clear, debugging becomes harder. A developer may assume a page updates instantly when it actually needs a rebuild, or assume a route is static when it is hitting the server on every request.
Finally, teams often ignore the cost of dynamic data fetching. SSR can show fresh information, but if every request triggers expensive work, the site may become slower or more fragile than necessary. The better approach is to reserve SSR for routes where freshness or personalization is genuinely worth the runtime cost.
A related pitfall is overusing client-side fixes after choosing SSR. If a route is server-rendered but still waits on extra browser-side fetching, you can end up with the complexity of SSR and the delay of client rendering. The cleaner pattern is to decide which data belongs on the server, which data can be cached, and which data can remain static before implementation starts.
A more subtle mistake is assuming all server-rendered routes should behave the same way. In reality, one SSR page may need cookies and redirects, another may only need fresh data, and another may be a simple endpoint that returns JSON. Treating them as one category can lead to over-engineering. The implementation should match the route’s actual job.
One more issue shows up in teams with multiple contributors: route ownership becomes unclear. If no one knows whether a page is meant to be static or dynamic, changes can accidentally break the rendering model. The fix is simple but important: document the intended mode in the route’s README, code comments, or project conventions so future edits do not drift.
Best practices and quick checklist
The best hybrid rendering setups are boring in the right way. They are predictable, route-scoped, and easy to explain to both developers and non-technical stakeholders.
Practical rules to follow
- Keep static as the default unless a route has a clear reason not to be static.
- Add an adapter before you depend on on-demand rendering.
- Use SSR for request-specific content, not for every page that merely changes sometimes.
- Document which routes are static and which are server-rendered.
- Review caching and data-fetching behavior for every SSR route.
- Prefer the smallest possible SSR surface area.
A useful checklist for implementation is simple: confirm the route’s business need, confirm the deployment runtime, confirm the rendering mode, and confirm how the data will be fetched and updated. If any of those four pieces is unclear, the route is not ready for SSR yet.
For teams working on merchant sites, it also helps to align rendering mode with content ownership. Marketing pages, editorial pages, and evergreen landing pages usually belong in the static bucket. Account pages, personalized dashboards, and operational views usually belong in the server-rendered bucket. That separation keeps the site easier to scale.
If you are building a content-heavy Astro site, this is also where structured content and rendering strategy meet. A route that uses a content model well can often stay static longer, while routes that depend on live state can be isolated. If you want a deeper look at that side of the stack, see Astro Content Collections for the content-structure angle.
A quick pre-launch checklist can save time:
- Is the route truly request-dependent?
- Does the adapter match the deployment target?
- Is the page intentionally static or intentionally dynamic?
- Are caching and headers defined for server-rendered responses?
- Does the team know how to update the content without guessing?
If the answer to any of those is no, pause before expanding SSR further. The best hybrid setup is one that is easy to operate after launch, not just one that works in local development.
It also helps to review the route after deployment, not just before it. A page can behave correctly in development and still need different cache rules or runtime settings in production. A short post-launch audit of the dynamic routes is often enough to catch mismatched headers, stale assumptions, or routes that should have stayed static.
From practice — illustrative scenario (hypothetical, not a client project)
Illustrative example — not a real client project: imagine a merchant site that sells a small catalog of products and also includes a customer account area. The homepage, product education pages, and editorial guides are stable enough to prerender. They rarely need per-visitor logic, and they benefit from static delivery. But the account area needs to show the logged-in customer their current order status, saved addresses, and a support message that depends on session data.
A typical merchant might start by building the whole site as static because that feels simpler. That works well for the public pages, but the account area quickly becomes awkward. The team either has to rebuild too often to keep information fresh, or they end up trying to fake personalization with client-side loading states. That can make the page feel slower and less reliable.
A more practical approach is to keep the public site static and mark only the account routes as server-rendered. The adapter is added for the chosen deployment runtime, the account page is opted out of prerendering, and the route reads the request data it needs at runtime. The public pages stay easy to cache and deploy, while the account area can respond to the current visitor.
The workflow would usually look like this: first, the team lists the routes that depend on a session or cookie. Next, they separate those routes from the marketing pages so there is no confusion about what rebuilds and what does not. Then they choose the adapter that matches the hosting platform and verify that the account route can read request data in the target runtime. Finally, they test the route with a logged-in and logged-out request to confirm that the page behaves correctly in both states.
That sequence matters because it prevents a common mistake: assuming the rendering mode alone solves the business problem. In reality, hybrid rendering is only one part of the solution. The data model, authentication flow, and deployment target all need to line up. If the account page is dynamic but the cache settings are wrong, the page may still behave unpredictably. If the route is marked dynamic but the team has not defined what happens when the session is missing, the user experience can still break.
The team might also decide to split the account area further. A summary page could be server-rendered because it needs to show the current user state, while a help article inside the same section could remain static. That kind of route-by-route decision is exactly where Astro hybrid rendering shines: it lets the architecture follow the content and the business rules instead of forcing every page into one mode.
The takeaway is not that SSR should replace static pages. The takeaway is that hybrid rendering lets each route do the least expensive thing that still satisfies the business requirement. In a real project, that usually means a smaller server surface, clearer architecture, and fewer reasons to rebuild the entire site for one changing page.
Related concepts and further reading
If you are deciding where SSR fits in an Astro project, these related guides help with the surrounding architecture. They are most useful when you are balancing content structure, performance, and deployment behavior.
- Astro content collections guide — useful when content can stay static but still needs a clean model.
- Astro islands architecture — helps separate static page delivery from interactive components.
- Astro view transitions guide — relevant when you want better navigation without changing rendering strategy.
- Astro Themes — browse Astro-ready themes when you want a faster starting point for a static or hybrid site.
- Astro — official category page for Astro-focused products and layouts.
Explore this topic
More Astro guides, glossary entries, and practical workflows live on the topic hub.
Frequently asked questions
What does Astro SSR hybrid rendering mean?
Astro SSR hybrid rendering is the practice of serving some routes as static HTML while rendering other routes on demand at request time. In Astro, that usually means keeping the default static build for most pages and opting specific pages or endpoints into server rendering. It is useful when a site has both stable marketing content and dynamic content that must change per visitor or per request.
When should I use SSR instead of static rendering in Astro?
Use SSR when a page depends on fresh data, cookies, authentication, or visitor-specific content. Static rendering is still the better default for pages that rarely change and do not need personalization. A hybrid approach works well when only a small part of the site needs server logic, because it keeps the rest fast and simple.
Do I need an adapter for Astro SSR?
Yes. Astro needs an adapter to run server-rendered routes on a specific runtime such as Node, Netlify, Vercel, or Cloudflare. The adapter tells Astro how to deploy and execute request-time rendering. Without it, you are limited to pre-rendered static output.
Can I mix static and SSR pages in the same Astro project?
Yes, that is the core idea behind hybrid rendering. You can keep most pages prerendered and mark only selected routes with `prerender = false`, or configure server output and opt specific pages back into static output. This gives you route-level control instead of forcing the whole site into one rendering mode.
What is the biggest risk with hybrid rendering?
The biggest risk is using SSR where static rendering would be enough. That can add runtime cost, deployment complexity, and more moving parts for caching and data fetching. The other common issue is inconsistency, where teams forget which pages are static and which are server-rendered, leading to unexpected behavior during updates or debugging.