Performance

Prerender first, hydrate second

How we use prerendering and light hydration to make enterprise sites fast without slowing down the team.

Written by

Daniel Okafor

Head of Platform

/ 5 min read

Key points

  • Prerender every route that is the same for every visitor. Serve real HTML from the edge.
  • Hydration should earn its place. Split by route and ship less JavaScript. A smaller bundle beats a deferred one.
  • Render per request only for authenticated, personalised, or session-dependent screens.

The fastest server request is the one that never happens. For content-heavy marketing sites and large parts of enterprise portals, most routes do not need a per-request render. They need a correct HTML document at the edge and a small amount of JavaScript to take over.

Angular’s hybrid rendering gives us three levers: server render per request, prerender at build time, and client render. The interesting decision is which route gets which one.

Default to prerender

If a page is the same for every visitor, prerender it. Product pages, service pages, documentation, case studies, and most marketing content fall into this bucket. Build-time rendering produces real HTML for crawlers and a first paint limited by the CDN. No Node process sits in the request path.

On Firebase Hosting that HTML is served from the edge with immutable asset caching. The server tier disappears from the hot path entirely. For a site like this one, every route is prerendered and the runtime cost of a page view is effectively zero.

Hydration should earn its place

Prerendered HTML still needs interactivity. The goal is to load less JavaScript. Split by route, keep shared UI small, and avoid importing a component library for four icons. Angular’s incremental hydration lets the page become interactive in pieces, but the biggest win is still not shipping the code at all.

We set a budget per route: initial JavaScript, font bytes, and largest contentful paint. Releases that exceed the budget fail the pipeline. A budget nobody enforces is a wish.

When to render per request

Authenticated dashboards, personalised pricing, and anything that depends on a session should not be prerendered. Those routes can render on the server or the client, depending on where the data lives and how much of the shell is shared.

The mistake is treating the whole application as one rendering mode. A route-level decision is easier to reason about, easier to cache, and much easier to explain to the person paying for infrastructure.

The payoff

A prerendered Angular site on a CDN is the correct architecture for a large class of business websites. It is fast everywhere, indexable by default, and cheap to operate. The interactivity is still there when it is needed.

Start with the routes that never change. Make them static. Then spend your complexity budget on the screens that genuinely need a server.

FAQ

Common questions.

What is prerendering in Angular?

Prerendering generates the HTML for a route at build time. Requests for that route receive static HTML that can be served from a CDN, with JavaScript hydrating the page for interactivity.

Is prerendering better than server-side rendering?

Neither is universally better. Prerendering is faster and cheaper for pages that are identical for every visitor. Server-side rendering fits authenticated, personalised, or session-dependent routes that cannot be built ahead of time.

Does prerendering hurt interactivity?

No. Prerendered HTML still hydrates into an interactive Angular application. The performance question is how much JavaScript the route ships and how quickly hydration completes.

Next step

Tell us how we can help you.

Tell us the constraint. A senior engineer will reply with a clear next step.

Start a project Direct reply from a senior engineer