Advertisement
Advanced .NET, Blazor (Server & WebAssembly)

What is prerendering in Blazor, and what problem does it solve for initial page load experience?

Short answer

Prerendering renders a component's initial HTML output on the server (without full interactivity yet) and sends it as part of the initial HTTP response, so users see meaningful content immediately instead of a blank page while the Blazor runtime (SignalR connection or WASM…

Save .NET mock interview
Advertisement
AModel answer
Prerendering renders a component's initial HTML output on the server (without full interactivity yet) and sends it as part of the initial HTTP response, so users see meaningful content immediately instead of a blank page while the Blazor runtime (SignalR connection or WASM download) initializes -- once the client-side runtime is ready, Blazor 'hydrates' the prerendered markup into a fully interactive component, ideally without a visible flash or layout shift.
// .NET 8 unified model: prerendering configured via render mode parameters
@rendermode @(new InteractiveServerRenderMode(prerender: true))

// Or globally for WebAssembly
@rendermode @(new InteractiveWebAssemblyRenderMode(prerender: true))
Real-world example
A public-facing Blazor WebAssembly app enables prerendering so search engine crawlers and users on slow connections see fully rendered initial content immediately, rather than a blank page during the multi-second WASM runtime download.
Likely follow-ups
  • What issues can arise if component code isn't idempotent-safe for running twice (prerender + real render)?
  • How does prerendering affect SEO for Blazor WebAssembly apps?
Related topics