jaffar.dev

Blazor features across .NET 6 to .NET 10

May 26, 2025 | by Jaffar Ali Mohamedkasim

blazor

Blazor Features Evolution: .NET 6 → .NET 10

Feature.NET 6.NET 7.NET 8.NET 10 (Latest)
Hosting ModelsWASM, Server+ Hybrid MAUIUnified model emergingUnified Server/WASM
AOT Compilation (WASM)ExperimentalImprovedOptimized + trimmingFaster & smaller AOT builds
Render ModesN/AN/ABasic hybrid setupPer-component @rendermode
Form ValidationBasicMinor updatesCustom input supportAsync & extensible validation
JS InteropManualJS module APITyped modulesImproved import/export + TS typing
RoutingStatic only+Route paramsRoute constraintsEnhanced deep linking + constraints
Razor ComponentsWeb onlyImprovementsShared across MAUIFull-stack Razor UI (static + server)
Streaming SSRN/AN/AInitial releaseStreaming rendering refined
Identity Support in WASMManual configMinimalIdentity + token helpersOut-of-box Identity with WASM
Blazor in .NET MAUIEarly HybridBetter syncPerformance boostTight native integration

.NET 10 Blazor Feature Code Examples

1. Render Modes Per Component

Now you can control how a component renders (Server, WASM, or Static)

@rendermode InteractiveServer
<!-- or -->
@rendermode InteractiveWebAssembly
<!-- or -->
@rendermode Static

<h3>This component renders using a custom mode!</h3>

2. Streaming Rendering in Server-Side Blazor

Renders HTML as it’s available, improving TTFB (enabled in Program.cs)

builder.Services.AddRazorComponents()
    .AddInteractiveServerComponents()
    .AddInteractiveWebAssemblyComponents()
    .AddStreamingRendering(); // 👈 new in .NET 10

3. Enhanced Routing with Constraints

Example: Only match numeric IDs

@page "/product/{id:int}"
@code {
    [Parameter]
    public int Id { get; set; }
}

4. Async Form Validation

Now you can validate forms asynchronously (e.g., check username availability)

<EditForm Model="@user" OnValidSubmit="@HandleValidSubmit">
    <InputText @bind-Value="user.Username" />
    <ValidationMessage For="@(() => user.Username)" />
</EditForm>

@code {
    private UserModel user = new();

    private async Task HandleValidSubmit()
    {
        // Async logic here
    }

    public class UserModel
    {
        [Required]
        [RemoteValidation] // Custom async validator
        public string Username { get; set; }
    }
}

5. JS Module Interop Improvements

You can now import JavaScript modules using clean syntax:

wwwroot/js/myModule.js

export function showAlert(msg) {
    alert(msg);
}

Blazor Component

@inject IJSRuntime JS

<button @onclick="ShowAlert">Click Me</button>

@code {
    private async Task ShowAlert()
    {
        var module = await JS.InvokeAsync<IJSObjectReference>("import", "./js/myModule.js");
        await module.InvokeVoidAsync("showAlert", "Hello from JS!");
    }
}

RELATED POSTS

View all

view all