SPA and Reactive Web
Blazor is Microsoft's web framework for building interactive applications with C# and Razor. Its component model makes it a natural fit for single-page experiences and reactive user interfaces.
Single-Page Application (SPA)
A SPA loads an application shell once, then updates its content as users navigate and interact. Blazor's client-side routing can move between app pages without a full document reload, much like React, Angular, or Vue.
Reactive Web UI
A reactive interface reflects its current data and state. When a component's C# state changes, Blazor renders the affected UI so the page stays in sync without manually editing the DOM.
What is Blazor?
Blazor brings C# and the .NET ecosystem to interactive web development. Developers compose pages from Razor components that combine HTML markup with C# logic. Forms, validation, navigation, and data-driven content can share the same language and application code.
Blazor hosting models
Blazor supports different ways to run interactive components, each with a different balance of client resources and server connectivity.
Blazor WebAssembly
The .NET runtime and app code are downloaded to the browser and run there through WebAssembly. The UI can run without a persistent connection to the server, while still calling backend APIs when the app needs them.
- Runs client-side in the browser
- Useful for apps that need client-side execution
Blazor Server
Components run on the server. Browser events travel over a SignalR connection, typically using WebSockets, and Blazor sends UI updates back to the page. This keeps the initial client download small and lets server code access backend resources.
- Runs C# component logic on the server
- Uses a live connection while interactive components are active
Components respond to state
Razor components own parameters and internal state. Events such as typing into an input update that state; Blazor's renderer then computes and applies the necessary UI changes. Most event handlers trigger a render automatically, while StateHasChanged() is available when code needs to request one explicitly.
Reactive data binding
The greeting updates as the bound C# value changes.
How the terms fit together
| Term | What it means |
|---|---|
| Single-Page Application (SPA) | An application architecture that updates page content without full document reloads during internal navigation. |
| Reactive Web UI | A user interface that responds to changes in component state and data. |
| Blazor | Microsoft's .NET framework for building web UI with C#, Razor components, and HTML. |