Static SSR vs Interactive Blazor: When to Opt‑In and What to Watch For
Static SSR gives lightning‑fast first paint and SEO, but no interactivity. Interactive modes let Blazor run on the server or WebAssembly, trading initial load size for real‑time UI. Learn how to assign @rendermode, what state means when you switch, and when to use each mode.
15 Nov 2025, 03:10 UTC

Why the Render Mode Matters
When you build a Blazor app, you often think of the framework as a single “client‑side” or “server‑side” experience. In .NET 8 the reality is a spectrum: components can render statically on the server, or become interactive on the client or server. Choosing the right mode for each component can shave milliseconds from the first paint, reduce bandwidth, or give you real‑time UI updates without a full page reload.
Static Server‑Side Rendering (Static SSR)
Static SSR renders a component’s HTML on the server and sends it to the browser as plain markup. No SignalR circuit is established, and the Blazor runtime is not downloaded. This is ideal for SEO‑heavy pages, landing pages, or content that rarely changes.
Key facts:
- Fastest initial load – no WASM or SignalR handshake.
- Best for search‑engine crawlers because the markup is fully present.
- Event handlers (e.g.,
@onclick) are inert; they never fire.
Interactive Modes: Server, WebAssembly, and Auto
Interactive components require a Blazor runtime. You can choose:
InteractiveServer– keeps a SignalR circuit, state lives on the server.InteractiveWebAssembly– downloads the entire app DLLs to the browser; state lives on the client.InteractiveAuto– starts asInteractiveServerfor the first load, then switches toInteractiveWebAssemblyonce the runtime is cached.
When you annotate a component with @rendermode, you lock that component into the chosen mode for the life of the page. If you mix modes, the component hierarchy must respect the rule that a static component cannot contain an interactive child unless the child is a separate component.
Concrete Example: A Counter That Can Be Static or Interactive
Below is a minimal Blazor component that can be rendered in any mode. The @rendermode attribute is optional; if omitted the component inherits the page’s mode.
@page "/counter"
@rendermode InteractiveAuto
Counter Demo
Count: @count
Increment
@functions {
private int count = 0;
private void Increment() => count++;
}
Deploy this component in a .NET 8 Blazor Web App and observe the following:
- Static SSR Page – Create a page that only contains static components and set the page’s
@rendermode Static. TheCountercomponent will render its final HTML but theIncrementbutton will never trigger because the runtime isn’t loaded. - Interactive Server Page – Change the page’s
@rendermode InteractiveServer. Open the browser DevTools, go to the Network tab, and watch for aSignalRconnection to/signalr. The button now updates the count via the server. - Interactive WebAssembly Page – Set the page’s
@rendermode InteractiveWebAssembly. In the Network tab you’ll see a larger payload (~8 MB for a typical app) as all DLLs are downloaded. After the first load, subsequent visits to the same page hit the cache and the button updates instantly on the client. - Interactive Auto – With
InteractiveAutothe first visit uses the server mode, then the browser caches the WASM runtime. Subsequent loads will switch to client‑side interactivity, giving you the best of both worlds.
State Transitions and Re‑Initialization
When a component switches from Static SSR to Interactive, the component is effectively re‑initialized. Any state held in fields or properties before the switch is lost unless you persist it elsewhere (e.g., a Scoped service or ProtectedSessionStorage). This is why a counter that lives inside a static page will start at zero on the first interactive load.
Trade‑Offs and Limitations
- Memory Footprint –
InteractiveServerkeeps a SignalR connection per user. For thousands of concurrent users this can strain server memory. - Payload Size –
InteractiveWebAssemblyrequires the entire app DLLs (~5–10 MB). On slow connections, the first interactive load can be noticeably slower than Static SSR. - SEO vs Interactivity – If a page needs both a crawler‑friendly markup and interactivity, you can render the core content statically and only opt‑in the interactive widgets with
@rendermode InteractiveServerinside the static page. However, remember that the parent must be a separate component; you cannot nest an interactive child inside a static parent component. - SignalR Overhead – SignalR uses WebSockets when available. If a corporate proxy blocks WebSockets, the interactive server mode will fall back to long polling, which can degrade performance.
How to Verify Your Choice
Use the following checklist to confirm that your render mode behaves as expected:
- Open the page in Chrome DevTools.
- Check the Network tab for a
signalrrequest (InteractiveServer). - Check the Network tab for a
.dllpayload (~8 MB) (InteractiveWebAssembly). - Verify that the
Incrementbutton triggers adotnet.jsevent when interactive.
- Check the Network tab for a
- Run
dotnet build -c Releaseand thendotnet run -c Releaseto see the server logs. A successful SignalR handshake will log a message likeSignalR connection established. - Navigate to a static page and confirm that clicking
Incrementdoes nothing (no network activity, no console errors). - Refresh a page that used
InteractiveAutoafter the first load and observe that the WASM payload is served from the cache (size drops to near zero).
Note: All commands should be run from the project root and require the user to have .NET 8 SDK installed. Elevated permissions are not needed for local development.
Actionable Takeaway
When designing a Blazor app, think in terms of “render mode buckets.” For SEO‑heavy or static content, keep the component @rendermode Static. For widgets that require real‑time updates, opt into InteractiveServer or InteractiveAuto and isolate them in separate components. Remember that switching modes re‑initializes state, so persist anything you need across renders in a scoped service or browser storage.
By strategically assigning render modes, you can deliver a snappy, SEO‑friendly experience while still harnessing Blazor’s interactivity where it matters most.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.