Build vs. Runtime in Web Projects
The rendering time is decided per route. Static, dynamic and incremental models can be combined according to data shelf life, cost and failure behavior.
Build vs. Runtime in Web Projects
When you set up a project, this decision takes one second: you pick a framework, accept the default and from then on render everything on the server. You only notice that second months later – when the build takes twenty minutes or the servers fill up at the first traffic spike.
The rendering time of a page is an architectural boundary, not a setting you configure away in the build setup. It determines when a page is created, how fresh its data is, what a failure costs and how fast a team can deliver. Still, the question – do we render at build time or at runtime? – usually gets answered implicitly. If you draw the boundary deliberately, you shorten cycles, cut costs and take friction out between content, development and operations.
The two points in time#
Every piece of output on the web is created at one of two points in time. At build time, work runs once, before any user arrives: templates become HTML, data gets frozen, assets get bundled and optimized. At runtime, work runs per request or in the browser while a user waits: data gets fetched, permissions checked, HTML assembled, state hydrated.
The key difference is not “fast vs. slow” but who waits and how often the work happens. Build work happens once and is delivered any number of times – the user never waits for it. Runtime work happens again on every request – in return, it knows the current moment, the logged-in user and the latest data.
flowchart LR
subgraph Build["Build-Zeit (einmal)"]
Content --> Prerender
Prerender --> StaticHTML["Static HTML + Assets"]
end
subgraph Runtime["Laufzeit (pro Request)"]
Request --> Fetch["Fetch data + auth"]
Fetch --> Render["Render + hydrate"]
end
StaticHTML --> CDN
CDN --> User
Render --> UserBetween these poles lies a spectrum, not an either-or: static site generation freezes everything at build time. Server-side rendering rebuilds per request. Client-side rendering pushes the work into the browser. And hybrid forms – prerendering plus client-side loading, or static HTML with incremental revalidation – mix both points in time per route. The art lies in drawing the boundary in the right place for each page instead of proclaiming one approach for everything.
The trade-off, concretely#
I tie the trade-off to three quantities, because exactly these three carry or slow down a product: freshness of data, cost per request and time to feedback in the team.
A marketing or documentation page rarely changes and is the same for everyone. Freezing it at build time is almost always right: afterward it sits as a static file in the CDN, costs practically nothing per request, has no server latency and no server that can fail.
// Build-time: runs once, per deploy
export async function getStaticProps() {
const posts = await cms.getPublishedPosts();
return { props: { posts } };
}
An account balance, a personalized dashboard or a price list that changes every hour can’t be frozen. This data belongs at runtime – either per request on the server or as a client-side fetch after the first paint.
// Runtime: runs on every request, knows "now" and the user
export async function getServerSideProps(ctx) {
const user = await auth(ctx.req);
const balance = await ledger.getBalance(user.id);
return { props: { balance } };
}
The real question is not “SSG or SSR?” but: How old may this output be without becoming wrong? I call that the data shelf life. If the shelf life is practically infinite (a blog post from 2019), the page belongs in the build. If the shelf life is zero (the current account balance), it belongs at runtime. And in between – the shelf life is minutes or hours – it gets interesting: then I want the delivery cost of a static asset, but a controlled refresh. That’s exactly what caching with revalidation and incremental regeneration exist for. They are the technical answer to a finite data shelf life, not a framework gimmick.
What this changes, measurably#
The reason I take this boundary so seriously is its effect on hard numbers.
A statically delivered page responds with the latency of the nearest CDN node – double-digit milliseconds, regardless of load. Rendering the same page on the server per request means database round trips, template rendering and a server that has to scale with traffic. During a traffic spike, that’s the difference between “the CDN delivers a file” and “our instances are maxed out and the autoscaling bill explodes.” For pages without a real data shelf life, runtime rendering is therefore not only more expensive but also more fragile – you buy complexity without getting anything in return.
Conversely, too much build work costs feedback. If every change to a post triggers a full rebuild of ten thousand pages, the build becomes the bottleneck: an editorial typo takes 20 minutes to become visible, and nobody dares to deploy shortly before the end of the day anymore. That’s not just a performance problem but a productivity problem. The consequence is not “more runtime” but a finer boundary: regenerate only the affected pages instead of everything. Shorter feedback loops are the real gain here – they decide how often a team ships and how calmly it does so.
A case I’ve come across in projects: a content-heavy portal historically renders everything on the server because that was once the framework default. Under normal load it works, but the server bill grows linearly with traffic, and every press release that makes the portal go briefly viral turns into an incident. If you move the dozen or so truly static page types – articles, categories, landing pages – into the build and leave only search and personalized areas at runtime, the curve changes fundamentally. The lion’s share of the traffic becomes a CDN file, the servers only carry the small dynamic remainder, and the traffic spike is suddenly a non-event. Not a single line of domain logic was rewritten – only the boundary between build and runtime was adjusted to the actual data shelf life.
That’s why I like to summarize the decision in a small table before I touch any tool:
| Page | Data shelf life | Point in time |
|---|---|---|
| Landing page, docs | practically infinite | Build |
| Product catalog | hours | Build + revalidation |
| Search result, feed | seconds | Runtime (server) |
| Dashboard, account balance | zero, personalized | Runtime (server/client) |
The table is deliberately simple. It forces exactly the one question you’d otherwise skip: how old may this be?
How I draw the boundary#
Before the tooling question, I clarify per route: is the output the same for all users or personalized? How old may it be? What happens if the data source doesn’t respond during rendering? And can the point in time be changed later without rebuilding half the application? If I slice a page so that I can move its rendering time in isolation – from build to runtime, to incremental or back – without touching neighboring routes, then the boundary is usable.
An often underestimated part of this is the lifetime of state. In the frontend, the hardest decision is rarely the component tree but the question of where state lives: in a component, in the URL, in a cache, on the server or in a local model. That question is the build-vs-runtime question in miniature. State that belongs in the URL can be rendered on the server and shared. State that exists only on the client requires runtime in the browser and is simply not present in the static HTML. If you get this mapping right, you get shareable, indexable, testable pages almost for free.
Progressive enhancement as the same boundary#
This way of thinking isn’t new; it has just grown old. Progressive enhancement has always asked: what do I deliver as a robust baseline, and what do I add at runtime if the client can handle it? Even a canvas element carries this attitude – first check whether a capability is there, then enable a behavior, otherwise offer a fallback.
<canvas id="clock" width="150" height="150">
<img src="clock.png" alt="Clock fallback" />
</canvas>
const canvas = document.getElementById("clock");
if (canvas.getContext) {
const ctx = canvas.getContext("2d");
// enhance at runtime, only when supported
}
Exactly the same order – capability, boundary, behavior – applies to server-delivered HTML plus client-side hydration. The static baseline is the build output. The enhancement is the runtime. If both layers are cleanly separated, the page works even when the runtime layer is slow or fails. That’s not outdated knowledge but the conceptual root of the whole rendering discussion.
The failure path decides#
A rendering decision only holds up once its failure path is described. What happens if the CMS doesn’t respond during the build – does the deploy abort, or does the page go live with a gap? What happens if an API hangs during server-side rendering – does the whole response block, or does the page render without that part and load it on the client? These questions seem dry, but they’re the difference between a demo and production.
Build rendering moves the risk of failure into the deploy pipeline: failures happen once, visibly, before any user sees them. Runtime rendering spreads the risk across every single request: failures happen live, under load, at the worst moment. Both are legitimate – but you should know which risk you’re buying. That’s why I always check whether the decision is reversible: can I switch a route from runtime to build when load increases? Can I invalidate a cache selectively without rebuilding everything? If the answer is no, part of the architecture is still missing.
Typical mistakes#
The first mistake is confusing the tool with the decision. An SSG framework is not an architecture, SSR is not a data model, a CDN is not a freshness strategy. These tools can express the boundary between build and runtime cleanly, but they don’t draw it for you. If you accept a framework’s default, you haven’t made a decision; you’ve skipped one.
The second mistake is orienting yourself on the happy path. In demo mode, every variant looks fast – one record, one user, no load. It gets interesting with ten thousand pages, with traffic spikes, with a slow upstream API, with an editor who wants to see a correction immediately. That’s exactly where it shows whether the boundary between build and runtime is in the right place.
Validation#
Three checks are usually enough for me. First: for every route, it’s stated whether it’s created at build time or at runtime – and why, expressed as a data shelf life. Second: for every runtime route, the failure path is described, including the behavior when the data source is down. Third: the decision can be switched per route without touching neighboring routes. Once these three points are in place, the architecture is robust against exactly the surprises that otherwise catch up with such projects late and expensively.
Further reading#
- React: Thinking in React: https://react.dev/learn/thinking-in-react
- React: Managing State: https://react.dev/learn/managing-state
The sources help you cross-check standards and platform behavior. The actual point remains the architecture decision in the concrete project.
Conclusion#
In the end, build vs. runtime is a question about the data shelf life of each individual page. An immutable post can go into the CDN as a file, an account balance needs current data, and many routes lie in between with revalidation. If this decision stays movable per route, a new need for freshness doesn’t have to overturn the rendering of the entire application.
Revised and translated from German with the help of AI.