Realtime pages with Blazor and SignalR in .NET 10
BlazorSignalR is the minimal, textbook version of realtime .NET web: a .NET 10 Blazor Web App (interactive server render mode) plus an explicit SignalR hub, showing the two ways content reaches a page live — server-generated push and user-generated broadcast.
Run it in one command
dotnet run --project BlazorSignalR
Open the Realtime page: every three seconds a hosted service pushes a telemetry reading to every connected browser. Open a second tab and type — every tab receives it. Those are the two directions, and everything else about realtime is elaboration.
The three pieces, and where each lives
Hubs/NotificationHub.cs— the SignalR hub at/hubs/notifications. It tracks attached clients and relaysBroadcastFromUserAsyncmessages to everyone.Services/RealtimeHubBridge.cs— aBackgroundServicethat keeps the connected-client proxies and broadcasts aTelemetryUpdateevery three seconds. Registered once as a singleton and as a hosted service, hub and push loop share a single source of truth.Components/Pages/Realtime.razor— an interactive component that wireshubConnection.On<T>(...)handlers and disposes them properly. The classic Blazor realtime bug is a leaked handler after navigation; this page shows the clean pattern.
Beginner notes
Blazor Server already feels "live" (the UI diffs arrive over its own circuit), so why SignalR? Because the circuit is per-user: the moment other users or background processes must update your page, you need a broadcast mechanism, and that is exactly SignalR. For the large, feature-complete version of the same ideas, see the Messenger-style chat article.
Repository: github.com/bobhuang1/BlazorSignalR