In the previous article, we saw how Blazor evolved from being “either WebAssembly or Server” to a much more powerful unified model. But knowing it exists is not the same as knowing how to use it well.
Today we’re going to get our hands dirty with the most important decision you’ll make when working with Blazor Web Apps in .NET 10: Which Render Mode should I choose for each part of my application?
“Render mode is not an implementation decision; it is an architectural decision.”
1. Why Render Modes Matter (A Lot)
Imagine you’re building an online store. Not all screens have the same requirements:
- The home page must load in milliseconds and be fully indexable by Google (SEO).
- The admin panel needs to be highly interactive and respond instantly to every click, without full-page reloads.
- The in-browser photo editing tool requires raw client-side execution power.
Previously, this forced you to stitch together different technologies (MVC + React + whatever else). With Blazor Web Apps, you can have a single .NET application where each section behaves in the most optimal way.
2. The 4 Modes at a Glance
Don’t choose a render mode based on “which technology you like best.” Choose based on the behavior the user needs in that specific part of the app.
| Mode | When to use it | When to avoid it |
|---|---|---|
| Static SSR | SEO, landing pages, blogs, content pages | Anything requiring interaction (no active circuit) |
| Interactive Server | Dashboards, internal CRMs, team tools | High-scale applications (each user maintains an open SignalR connection) |
| Interactive WebAssembly (WASM) | Heavy editors, client-side intensive calculations, offline apps | Slow initial load (the browser must download the .NET runtime) |
| Interactive Auto | Most modern interactive applications | When you need full environment control or the component behaves very differently on server vs. client |
3. Interactive Auto: The Smart Choreography Between Server and Client
This is the mode that causes the most confusion initially, but it’s also the most powerful once understood.
It’s not magic; it’s a well-thought-out sequence:
- Server Prerender: The user arrives and receives near-instant static HTML (just like in Static SSR). Perceived speed is excellent.
- Interactive Server: Meanwhile, a SignalR connection is established so the user can interact immediately.
- Background WASM Download: The browser silently downloads the .wasm files while the user browses.
- Handoff: On the next navigation or reload, Blazor detects that everything is in place and shifts full execution to the client.
“Auto is not magic: it’s a well-executed choreography between server and client.”
Watch out for prerendering: During step 1, your component executes twice: once on the server (to generate the initial HTML) and once on the client (to enable interactivity).
This means code with side effects in OnInitializedAsync() (such as API calls) can run twice. The recommended solution is to move that logic to OnAfterRenderAsync(firstRender) or disable prerendering when it’s not needed. We will dive deeper into this behavior in the next article.
4. Applying Render Modes with Precision
Blazor allows you to be as granular as you need. You can define the mode globally in App.razor, but my strong recommendation is to apply it per page or per component.
Example on a specific page:
@page "/dashboard"
@rendermode InteractiveServer
The golden rule: Start with a simple global strategy (Static SSR by default) and “break the rule” only where you genuinely need interactivity. This keeps your application lightweight and scalable.
5. A Real-World Example: Task Manager
To keep this from being purely theoretical, we built a complete task management application that combines multiple modes tailored to each section’s needs.
Registering Services: The Gotcha That Bites
The secret lies in registering services so they work properly across all contexts:
// Program.cs (tanto en el proyecto Server como en el Client)
builder.Services.AddSingleton<ITaskService, MockTaskService>();
Be careful with server lifetimes: A
Singletonin the server project is shared across all users. If the service manages per-user state (shopping cart, preferences, etc.), useScopedon the server side. In WASM, this is not an issue because each browser tab is an isolated process.
/ (Home) → Static SSR
A pure landing page. Instant loading, no open WebSockets. This is where SEO lives.
@page "/"
<PageTitle>Home</PageTitle>
<h1>Bienvenido al Task Manager</h1>
<p>Esta página se renderiza completamente con Static SSR.</p>
/tasks → Interactive Server
This is where you manage tasks: creating them, toggling completion, etc. Everything is processed on the server with an immediate response powered by SignalR.
@page "/tasks"
@rendermode InteractiveServer
@inject ITaskService TaskService
<!-- lógica de la lista de tareas -->
/analytics → Interactive Auto
The metrics and charts section. This component lives in the .Client project. The initial visit receives server-rendered HTML while WASM downloads in the background. On subsequent visits, everything runs directly on the client without burdening the server.
@page "/analytics"
@rendermode InteractiveAuto
@inject ITaskService TaskService
<div class="progress">
<div class="progress-bar" style="width: @percentage%;">@percentage%</div>
</div>
@code {
private List<TaskItem> tasks = new();
private double percentage;
protected override async Task OnInitializedAsync()
{
tasks = await TaskService.GetTasksAsync();
var completed = tasks.Count(t => t.IsCompleted);
percentage = tasks.Count > 0
? Math.Round((double)completed / tasks.Count * 100, 1)
: 0;
}
}
The Right Choice Exists, and It Depends on Your Use Case
Choosing the right Render Mode is the first major step toward a Blazor application that is fast, scalable, and pleasant to use. The table above serves as a quick reference, but the most practical rule of thumb is this:
Always start with Static SSR and add interactivity only where the user genuinely needs it.
When you mix multiple modes within the same application, a subtle yet crucial issue emerges: state can “disappear” between contexts, and some components execute more times than expected (as we saw with prerendering in Auto).
In the next article, we’ll dive deep into exactly that: why your component seems to run twice and how to handle state and lifecycle events when bridging these worlds without breaking your app.
In the meantime, you can explore the complete project we used as an example here: TaskManagerApp on GitHub
Are you currently working on a Blazor Web App project? Which render mode are you using the most? Let me know in the comments—we can certainly share some useful tips.