Blazor vs React: The Same Ideas in Two Stacks
November 5, 2026 · 10 min read
Blazor, React, C#, .NET, TypeScript, Interview Prep
If you know one of these stacks, the fastest way to learn the other is to map it onto what you already know. (The Blazor Learning Path and the React Learning Path cover each one on its own.) Most concepts line up one to one. The differences that matter are about where code runs and how state changes reach the screen.
This post is that map: a summary table, then the same small features written both ways.
The map
| Concept | React | Blazor |
|---|---|---|
| Component | Function returning JSX (.tsx) | .razor file: markup plus an @code block |
| Inputs | Props (function arguments) | [Parameter] properties |
| Passing markup | children | RenderFragment ChildContent |
| Child → parent | Callback prop (onSave) | EventCallback<T> parameter |
| Local state | useState / useReducer | Private fields |
| Re-render trigger | Calling a state setter | Event handler completes, or StateHasChanged() |
| Side effects | useEffect | Lifecycle methods (OnInitializedAsync, OnParametersSetAsync, OnAfterRenderAsync) |
| Shared values down the tree | Context | Cascading values |
| App-wide services | Modules, context, hooks | Dependency injection (@inject) |
| Shared state store | Zustand, Redux Toolkit | State container service, Fluxor |
| Server data cache | TanStack Query | Typed HttpClient + your own caching, or [PersistentState] for prerendering |
| Forms | Controlled inputs, React Hook Form + Zod | EditForm, InputText, DataAnnotations or FluentValidation |
| List identity | key | @key |
| Error containment | Error boundary (class component) | <ErrorBoundary> component |
| Routing | React Router, or the framework's router | Built in: @page, NavLink, NavigationManager |
| Server rendering | SSR + hydration, React Server Components | Render modes: static SSR, Interactive Server, WebAssembly, Auto |
| Component tests | React Testing Library | bUnit |
| Language | TypeScript / JavaScript | C# |
Components and props vs parameters
React
type BookCardProps = {
title: string;
author?: string;
isFavourite?: boolean;
children?: React.ReactNode;
onFavourite: (title: string) => void;
};
function BookCard({ title, author = "Unknown", isFavourite = false, children, onFavourite }: BookCardProps) {
return (
<div className="book-card">
<h3>{title}</h3>
<p>by {author}</p>
{isFavourite && <span className="badge">Favourite</span>}
{children}
<button onClick={() => onFavourite(title)}>Favourite</button>
</div>
);
}
Blazor
<div class="book-card">
<h3>@Title</h3>
<p>by @Author</p>
@if (IsFavourite)
{
<span class="badge">Favourite</span>
}
@ChildContent
<button @onclick="() => OnFavourite.InvokeAsync(Title)">Favourite</button>
</div>
@code {
[Parameter, EditorRequired] public string Title { get; set; } = "";
[Parameter] public string Author { get; set; } = "Unknown";
[Parameter] public bool IsFavourite { get; set; }
[Parameter] public RenderFragment? ChildContent { get; set; }
[Parameter] public EventCallback<string> OnFavourite { get; set; }
}
Almost the same shape. React's props are function arguments; Blazor's parameters are properties the framework sets. Both forbid a component from changing its own inputs, and both send data down and events up.
State and re-rendering
This is the deepest difference.
React: state is immutable snapshots. You call a setter with a new value, and React re-renders:
function ReadingGoal() {
const [goal, setGoal] = useState(12);
const [read, setRead] = useState(0);
const percent = goal === 0 ? 0 : Math.floor((read * 100) / goal);
return (
<>
<input type="number" value={goal} onChange={(e) => setGoal(Number(e.target.value))} />
<p>{read} of {goal} read ({percent}%)</p>
<button onClick={() => setRead((r) => r + 1)} disabled={read >= goal}>I finished a book</button>
</>
);
}
Blazor: state is ordinary mutable fields. You change them in an event handler, and Blazor re-renders after the handler finishes:
<input type="number" @bind="goal" @bind:event="oninput" />
<p>@read of @goal read (@Percent%)</p>
<button @onclick="MarkRead" disabled="@(read >= goal)">I finished a book</button>
@code {
private int goal = 12;
private int read;
private int Percent => goal == 0 ? 0 : read * 100 / goal;
private void MarkRead() => read++;
}
The consequences, in both directions:
- Blazor has no stale-closure problem. A handler reads the field, not a snapshot from an old render. React's "why does my interval see the old count?" bug doesn't exist.
- Blazor needs a nudge when changes come from outside an event. A timer, a service event or a background task changing a field won't update the screen until you call
InvokeAsync(StateHasChanged). React re-renders on any setter call, wherever it comes from. - Mutation makes "did it change?" harder. React can compare references because state is immutable. Blazor can't, so a parent re-render re-renders children with complex parameters by default, and skipping renders (
ShouldRender) is easiest when you use immutable records anyway. - Two-way binding is built in. Blazor's
@bindreplaces React'svalueplusonChangepair.
Effects vs lifecycle methods
React: one hook, useEffect, configured by its dependency array:
function BookDetails({ id }: { id: number }) {
const [book, setBook] = useState<Book | null>(null);
useEffect(() => {
const controller = new AbortController();
setBook(null);
fetch(`/api/books/${id}`, { signal: controller.signal })
.then((r) => r.json())
.then(setBook)
.catch(() => {});
return () => controller.abort();
}, [id]);
return book ? <h1>{book.title}</h1> : <p>Loading…</p>;
}
Blazor: named lifecycle methods:
@if (book is null)
{
<p>Loading…</p>
}
else
{
<h1>@book.Title</h1>
}
@code {
[Parameter] public int Id { get; set; }
private Book? book;
protected override async Task OnParametersSetAsync()
{
book = null;
book = await Books.GetBookAsync(Id);
}
}
OnParametersSetAsync plays the role of useEffect(..., [id]), OnInitializedAsync is roughly useEffect(..., []), OnAfterRenderAsync is where DOM work happens (like useLayoutEffect for JS interop), and Dispose is the effect cleanup. Blazor's version is more explicit; React's is more composable (custom hooks bundle state and effects together in a way Blazor has no direct equivalent for; services and base classes fill that role).
Both have a "runs twice" surprise: React's StrictMode double-invokes effects in development, and Blazor's prerendering runs OnInitializedAsync on the server and again when interactive, in production too.
Context vs cascading values, and where DI fits
React
const ThemeContext = createContext<Theme | null>(null);
<ThemeContext value={theme}>
<App />
</ThemeContext>
function ThemedButton({ children }: { children: React.ReactNode }) {
const theme = useContext(ThemeContext);
return <button className={theme?.isDark ? "btn-dark" : "btn-light"}>{children}</button>;
}
Blazor
<CascadingValue Value="theme">
@ChildContent
</CascadingValue>
<button class="@(Theme?.IsDark == true ? "btn-dark" : "btn-light")">@ChildContent</button>
@code {
[CascadingParameter] public Theme? Theme { get; set; }
[Parameter] public RenderFragment? ChildContent { get; set; }
}
Same idea, same caveat: every consumer re-renders when the value changes.
The bigger difference is that Blazor has a real dependency injection container. In React, "how does this component get the API client?" is answered by module imports, context or custom hooks. In Blazor it's @inject BooksApiClient Api, with lifetimes managed for you. Shared state usually becomes a scoped service rather than a context provider. For .NET developers that feels natural; for React developers it's the part that takes getting used to, especially that Scoped means per user circuit on the server and per tab in WebAssembly.
Forms
React: controlled inputs, or React Hook Form with a Zod schema that also gives you the TypeScript type.
Blazor: EditForm with input components and a validator component:
<EditForm Model="book" OnValidSubmit="SaveAsync" FormName="add-book">
<DataAnnotationsValidator />
<InputText @bind-Value="book.Title" />
<ValidationMessage For="() => book.Title" />
<button type="submit">Add book</button>
</EditForm>
Blazor's real advantage is sharing validation with the server: the same C# model and validator can run in the browser and in the API. In a React app with a .NET backend, the rules are written twice (Zod and C#) unless you generate one from the other.
Rendering on the server
Both ecosystems moved toward the server at the same time, in different shapes:
| React | Blazor | |
|---|---|---|
| HTML on first load | SSR, then hydration | Static SSR, or prerendering of interactive components |
| Components that never ship to the browser | Server Components | Static SSR components |
| Interactive, running in the browser | Client Components ("use client") | Interactive WebAssembly |
| Interactive, running on the server | No direct equivalent | Interactive Server over SignalR |
| Stream slow parts | Suspense + streaming SSR | [StreamRendering] |
| Server mutations from the UI | Server Functions ("use server"), Actions | Form posts to static SSR components, or API calls |
The one with no React equivalent is Interactive Server: the UI runs on the server and only DOM diffs travel over the wire. It means fast start-up and no API layer for internal tools, at the cost of a persistent connection per user and latency on every click.
Choosing between them
| Lean towards… | When |
|---|---|
| Blazor | The team is .NET-first; it's an internal or line-of-business app; you want shared C# models and validation end to end; Interactive Server's "no API layer" is attractive |
| React | It's a public, consumer-facing product where bundle size and first load matter most; you need the biggest ecosystem of UI libraries; you're hiring front-end specialists; you want the most deployment options |
| Either | A back-office app with a .NET API. Both work well; the team's skills decide it |
In the wild: a very common enterprise split is a React front end with a .NET API: two languages, two build pipelines, DTOs defined twice and kept in sync by hand or by generating TypeScript from OpenAPI. Teams that move to Blazor usually do it to collapse that split into one language, and the shared models and validation are the immediate win. The gotcha is the ecosystem: sooner or later the app needs a chart, a map or a rich-text editor, and that means JavaScript interop anyway. It's worth deciding early how JS is loaded; self-hosted files and collocated modules hold up best.
Check yourself: questions and answers
1. What's the biggest conceptual difference between React and Blazor?
How state triggers rendering. React uses immutable state and re-renders when a setter is called; Blazor uses mutable fields and re-renders after event handlers or an explicit StateHasChanged.
2. What's Blazor's equivalent of useEffect?
Lifecycle methods: OnInitializedAsync for "once", OnParametersSetAsync for "when inputs change", OnAfterRenderAsync for DOM work, and Dispose for cleanup.
3. Context vs cascading values?
Same purpose: pass a value down without prop drilling. Both re-render consumers when the value changes; Blazor's IsFixed opts out for values that never change.
4. Does React have anything like Interactive Server?
Not directly. Server Components render on the server but aren't interactive; interactivity in React runs in the browser. Interactive Server keeps the component running on the server and sends UI diffs over SignalR.
5. When would you choose Blazor over React?
For a .NET team building internal or line-of-business apps where sharing C# models and validation between client and server matters more than bundle size or the breadth of the JavaScript ecosystem.
Further reading
- The series: Blazor Learning Path (Part 2, Part 3) and React Learning Path (Part 2, Part 3)
- Microsoft Learn, ASP.NET Core Blazor and Render modes
- React docs, Thinking in React and Server Components
- Microsoft, eShop reference application
Thoughts on this?
Tell me on X: @bobbyencoded · Share this post on X
Want more like this? Subscribe to The Decode, a weekly email on the AI and developer news worth your time.