Covers the four Blazor Web App render modes (static SSR, Interactive Server, Interactive WebAssembly, Interactive Auto), where code runs, prerendering, how modes are applied, and the trade-offs that drive the choice.
A Blazor Web App decides per component where rendering happens. Static SSR (the default) renders HTML on the server for each request with no live interactivity, like Razor Pages. Interactive Server keeps component state on the server in a circuit and sends UI diffs over a SignalR WebSocket. Interactive WebAssembly downloads the .NET runtime and your assemblies and runs components in the browser, calling your API over HTTP. Interactive Auto starts on Server for a fast first load, then uses WebAssembly on later visits once the bundle is cached.
Interactive modes prerender on the server by default. The trade-off: Server is quick to start and keeps code private, but costs latency on every click and memory per connected user; WebAssembly scales cheaply but has a multi-megabyte first download.
"Since .NET 8, Blazor is one app model with render modes, and .NET 10 keeps that model. In a Blazor Web App, a component that has no render mode, and is not inside an interactive parent, is rendered with static server-side rendering: the server runs it once per request, sends HTML and forgets it. The project template can instead make the whole app interactive by putting a mode on
Routes, so the effective default depends on how the app was created. Static SSR is great for content pages and forms that post back, and with streaming rendering and enhanced navigation it still feels fast. When a component needs real interactivity, I give it an interactive render mode.Interactive Server runs the component on the server inside a circuit, one per browser tab, connected by a SignalR WebSocket. A click goes to the server, the component re-renders, and Blazor sends a small DOM diff back. It starts instantly and the code never leaves the server, but every interaction pays a network round trip and every connected user holds server memory. Interactive WebAssembly downloads the .NET runtime and the app's assemblies to the browser and runs the component there; it is fully client-side, so it must call an API for data, and the first visit downloads a few megabytes. Interactive Auto uses Server first and switches to WebAssembly on later visits once the files are cached. Interactive modes are prerendered by default: the server sends real HTML first, which gives search engines content to index and gives users something to see while the circuit or runtime starts, and then the component becomes interactive.
The mistake I see is turning on Interactive Server globally for everything 'because it is easiest', then discovering at go-live that 2,000 concurrent users need sticky sessions and gigabytes of RAM. I default to static SSR and add interactivity only where a page needs it."
| Mode | Where code runs | Transport | First load | Per-interaction cost | SEO | Typical use |
|---|---|---|---|---|---|---|
| Static SSR | Server, per request | Plain HTTP | Fastest | Full request (enhanced nav patches the DOM) | Best: full HTML | Content, dashboards that refresh, simple forms |
| Interactive Server | Server, in a circuit | SignalR (WebSocket) | Fast | Network round trip | Good if prerendered | Internal LOB apps, low-latency networks |
| Interactive WebAssembly | Browser (.NET on WASM) | HTTP calls to your API | Slow first visit, cached after | Local, no round trip | Good only if prerendered | Rich client UIs, offline-ish, many users |
| Interactive Auto | Server first, then browser | SignalR, then HTTP | Fast | Round trip at first, local later | Good if prerendered | Public apps wanting both |
@rendermode InteractiveServer.<Counter @rendermode="InteractiveWebAssembly" />.<Routes> and <HeadOutlet> in App.razor, which makes the whole app interactive (and turns on client-side routing). The dotnet new blazor --interactivity ... --all-interactive option generates this.RenderFragment child content across that boundary)..Client project, because that assembly is what ships to the browser.Prerendering runs the component once on the server to produce HTML, then again when it becomes interactive. It improves perceived load time and SEO, but without care OnInitializedAsync runs twice and data loads twice, with a visible flicker. In .NET 10 the fix is the declarative [PersistentState] attribute; you can also turn prerendering off with new InteractiveServerRenderMode(prerender: false), at the cost of a blank area until the component is interactive.
| Concern | Static SSR | Interactive Server | WebAssembly |
|---|---|---|---|
| Server load | CPU per request only | CPU + memory per connected tab | Static files + API calls |
| Low-end phones | Best | Good (thin client) | Slowest start |
| Unhandled exception | Error page for that request | Circuit is terminated; user sees the error UI and must reload | Error UI in the browser; logged only if you send it to telemetry |
| Logs | Server logs | Server logs | Browser; ship to Application Insights |
In interactive modes I wrap risky areas in <ErrorBoundary> so one failing widget does not kill the whole circuit.
| Situation | My choice |
|---|---|
| Marketing or content pages, SEO matters | Static SSR, streaming rendering |
| Internal app, staff on the corporate network or Azure Australia East close by | Interactive Server for the interactive parts |
| Public app, thousands of concurrent users, mobile networks | WebAssembly or Auto for interactive parts |
| Code or rules must not reach the browser | Static SSR or Server |
| Needs to keep working with flaky connectivity | WebAssembly |
On an internal claims app for [team size] users, we started with global Interactive Server. Moving the read-only list and detail pages to static SSR and keeping Interactive Server only for the claim editor cut active circuits by about [70%] and peak memory from [~3 GB to ~1 GB] per instance, with no change users noticed.
Checks that the candidate knows where Blazor code actually runs in each mode and can choose a mode from scale, latency and security, not habit.
Green flags
Red flags
DbContext in a WebAssembly componentA Razor component is just a class that builds a render tree. What changes between modes is who runs that class and how the output reaches the DOM.
Static SSR:
Browser --GET /orders--> Server: run component -> HTML -> response, component discarded
Interactive Server:
Browser <==== SignalR WebSocket (circuit) ====> Server: component lives here
click event ----> handler runs, re-render, diff
DOM patch <---- render batch (binary)
Interactive WebAssembly:
Browser: dotnet.wasm runtime + your .Client assemblies
click -> handler runs locally -> DOM patched locally
data -> HttpClient -> your ASP.NET Core API
For Interactive Server, each browser tab gets a circuit: the component instances, their state and a DI scope. Scoped services live as long as the circuit, not the HTTP request. If the WebSocket drops, the server keeps the circuit for a retention period (three minutes by default) so the client can reconnect. In .NET 10, Blazor can also persist circuit state so a user can resume after the circuit was evicted. Memory is the cost: every connected tab holds its component tree on the server.
The browser downloads dotnet.wasm (the runtime), the framework assemblies and your .Client assemblies, trimmed and compressed. Typical apps are a few megabytes compressed on first visit and then cached and fingerprinted. Code runs on the browser's main thread. Anything in the .Client project is public: never put secrets or privileged logic there, and treat every API call from it as untrusted.
Auto picks Server when the WebAssembly files are not cached yet and starts downloading them in the background. On a later visit, when they are cached, the component starts as WebAssembly. Your component therefore must work in both: it cannot inject a DbContext directly, because that will fail in the browser. The usual pattern is an interface such as IOrderService with a server implementation that uses EF Core and a client implementation that calls the API.
You register the modes you use (AddInteractiveServerComponents, AddInteractiveWebAssemblyComponents) and map them (AddInteractiveServerRenderMode, AddInteractiveWebAssemblyRenderMode). A mode you did not register throws at runtime when a component asks for it.
dotnet new blazor -int Auto -o RenderModes and open the Counter page with dev tools open: watch the WebSocket on the first visit, then the .wasm downloads, then reload and see it run locally.Console.WriteLine in OnInitializedAsync of a prerendered page and see it run twice. Then add [PersistentState] and see the second load skipped.@rendermode InteractiveServer on a component inside a WebAssembly parent and read the error.wwwroot/_framework size with du -sh after dotnet publish -c Release.Register the modes in Program.cs, then apply them per component or globally.
// Program.cs (server project)
using RenderModes.Components;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents() // circuits over SignalR
.AddInteractiveWebAssemblyComponents(); // .Client assembly runs in the browser
var app = builder.Build();
app.UseHttpsRedirection();
app.UseAntiforgery();
app.MapStaticAssets();
app.MapRazorComponents
DbContext into a component that uses WebAssembly or Auto. Why it is wrong: the component runs in the browser, where there is no database connection. Instead: depend on an interface with a server implementation and an HTTP client implementation.OnInitializedAsync twice. Why it is wrong: data loads twice and the UI flickers. Instead: use [PersistentState] in .NET 10 or disable prerendering for that component..Client project. Why it is wrong: those assemblies are downloaded and can be decompiled. Instead: keep them on the server behind an authorised API.@onclick on a component rendered with static SSR and expecting it to fire. Why it is wrong: the markup compiles and renders, but static SSR sends HTML only and no circuit or runtime is attached to handle the event. Instead: use a form post, or give that component (or a small child) an interactive render mode.The render mode is an architecture decision per page, not a project setting. I decide it from three numbers: concurrent users (memory per circuit), user latency to the server (Australia to a US region adds 150+ ms per click), and acceptable first-load size. For an internal app in Azure Australia East with a few hundred staff, Interactive Server is productive and cheap. For a public app with thousands of mobile users, WebAssembly or Auto for the interactive parts and static SSR for the rest.
| Option | When it fits | Cost | When not to |
|---|---|---|---|
| Static SSR | Content, SEO, read-mostly pages | No interactivity without forms/JS | Rich editors, drag and drop |
| Interactive Server | Internal apps, low latency, private logic | RAM per circuit, sticky sessions, round trips | Many thousands of users far from the region |
| Interactive WebAssembly | Rich client UI, scale, offline-ish | Download size, needs an API, code is public | Low-end devices, secret logic |
| Interactive Auto | Public apps wanting fast first load and client-side scale | Two hosting models to test, interface per data source | Small internal apps (unneeded complexity) |
I measure it: Lighthouse for first load, circuit counts and memory per instance for Server, and real user latency from Application Insights.
A SignalR server only knows its own connections and groups, held in memory. Scale out to several instances and Clients.Group("x") on server A never reaches users connected to server B. Self-hosted, you also need sticky sessions, because the negotiate request and the SSE or long-polling requests must reach the same server (WebSockets-only with SkipNegotiation avoids that). Affinity costs you even load distribution, and clients on a failed instance must reconnect. The Redis backplane fixes delivery by publishing every message to every server. It works well at moderate scale, but every server processes every message, and pub/sub doesn't buffer during a Redis failover, so run Redis highly available. Azure SignalR Service moves the client connections off your app: your servers keep a handful of connections to the service, which handles fan-out, at about 1,000 concurrent connections per Standard unit.
For 100,000 connections, I would use Azure SignalR Service, plan units from peak connections and fan-out, and design for reconnect storms.
I would treat it as an architecture decision record, not a preference vote. First list the constraints: users and devices, connectivity, accessibility, how long the app lives and who will maintain it. Then score the options on weighted criteria: team skills and hiring, ecosystem and components, render and hosting model, security fit, performance on real devices and long-term maintenance.
Rough guidance: Blazor fits a .NET-only team building internal apps, sharing C# models and validation, if you choose the render mode carefully. React fits when the UI is complex or customer-facing and you can hire frontend specialists. Angular fits large teams that value one opinionated structure.
Reduce the risk with a time-boxed spike on the hardest screen and record the outcome in an ADR with triggers for revisiting it. The trade-off is usually team productivity now against ecosystem and hiring breadth later.
SignalR is ASP.NET Core's real-time framework. A hub is a class whose public methods clients call, and the server calls methods on clients through Clients.All, Clients.Group(...) or Clients.User(...). Hubs are transient, created per invocation, so they hold no state. On connect the client calls negotiate and uses the best transport available: WebSockets, then Server-Sent Events, then long polling. Groups fan messages out to subsets of connections, but they live in memory, so a reconnecting client must re-join them (usually in OnConnectedAsync). Strongly typed hubs (Hub<IOrderClient>) replace method-name strings with an interface. Authentication uses the normal pipeline with [Authorize]. Browsers can't send an Authorization header on WebSockets or EventSource, so as a workaround the token travels as an access_token query parameter, read in JwtBearerEvents.OnMessageReceived.
The trade-off: reconnects and routing come free, but every client holds a stateful connection that you must plan to scale.
Last updated 23 Nov 2026.