Interactive Server Rendering
Interactive Server makes components respond to clicks and typing while the code keeps running on the server.
On this page · 5 min · Beginner
On this page
- Learning objectives
- Explanation
- Code example
- Step by step
- Real-world use
- Common mistakes
- Best practices
- Remember this
- Practice exercise
- Mini quiz
- Related topics
- My notes
- Reading time
- 5 min
- Difficulty
- Beginner
- Updated
- Oct 29, 2026
Related tutorials
Learning objectives#
- Enable Interactive Server rendering
- Explain circuits and their costs
- Handle disconnection and reconnection
- Decide when to use it
Explanation#
Register it with AddInteractiveServerComponents() and AddInteractiveServerRenderMode(), then apply @rendermode InteractiveServer to a page or component.
Each user gets a circuit: a SignalR connection plus server memory holding component state. UI events travel to the server; DOM diffs travel back.
Advantages: fast first load, full server access (databases, files), code never leaves the server. Costs: latency on every interaction, memory per user, and the UI stops when the connection drops.
Code example: Enabling Interactive Server#
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();
var app = builder.Build();
app.UseStaticFiles();
app.UseAntiforgery();
app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode();
app.Run();
// In a component: @rendermode InteractiveServer
Components marked @rendermode InteractiveServer now handle events. The browser keeps one WebSocket open per tab.
This example is illustrative. Copy or download it and run it in your own environment; the expected output is shown above.
Step-by-step explanation#
- AddInteractiveServerComponents registers the server-side services.
- AddInteractiveServerRenderMode maps the SignalR hub endpoint.
- Antiforgery protection is required by Blazor Web Apps.
- Only components that opt in become interactive.
Real-world use case#
An internal stock management screen used by 50 staff on a company network: low latency, direct database access and no API layer needed.
Common mistakes#
Thousands of circuits need memory and sticky sessions. Consider static SSR or WebAssembly for public pages.
Mobile networks drop. Customise the reconnect UI and keep state you cannot lose outside the circuit.
Best practices#
- Use for internal or low-latency apps
- Enable WebSockets on the host
- Use sticky sessions or Azure SignalR Service when scaling out
- Keep per-user state small
Remember this#
Interactive Server = events over SignalR, code stays on server.
One circuit per user = memory + connection.
Fast start, but every click is a round trip.
Practice exercise#
Your task: Which two calls enable Interactive Server in Program.cs?
Show solution
builder.Services.AddRazorComponents().AddInteractiveServerComponents();
app.MapRazorComponents<App>().AddInteractiveServerRenderMode();
Mini quiz#
What happens to an Interactive Server page when the network connection drops?
Want more? Practise all Blazor MCQs · Blazor interview questions
My notes#
Saved in this browser.