Blazouter.Server 1.0.13

Prefix Reserved
dotnet add package Blazouter.Server --version 1.0.13
                    
NuGet\Install-Package Blazouter.Server -Version 1.0.13
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Blazouter.Server" Version="1.0.13" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Blazouter.Server" Version="1.0.13" />
                    
Directory.Packages.props
<PackageReference Include="Blazouter.Server" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Blazouter.Server --version 1.0.13
                    
#r "nuget: Blazouter.Server, 1.0.13"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Blazouter.Server@1.0.13
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Blazouter.Server&version=1.0.13
                    
Install as a Cake Addin
#tool nuget:?package=Blazouter.Server&version=1.0.13
                    
Install as a Cake Tool

Blazouter.Server

NuGet NuGet Downloads

Server-side specific extensions for Blazouter - the React Router-like routing library for Blazor applications. This package provides necessary components and extensions for Blazor Server applications.

Features

  • ✅ Blazor Server integration
  • ✅ All core Blazouter features
  • ✅ Server-side rendering support
  • ✅ Enhanced routing for server mode
  • ✅ Optimized for server-side performance

Installation

dotnet add package Blazouter
dotnet add package Blazouter.Server

Note: This package requires the core Blazouter package.

Quick Start

1. Configure Services

// Program.cs
using Blazouter.Extensions;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddRazorComponents()
    .AddInteractiveServerComponents();

builder.Services.AddBlazouter(); // Add Blazouter services

var app = builder.Build();

2. Add Blazouter Support to Routing

Important: Add AddBlazouterSupport() to enable Blazouter routing in server mode:

using Blazouter.Server.Extensions;

app.MapRazorComponents<App>()
    .AddBlazouterSupport()  // Required for Blazouter
    .AddInteractiveServerRenderMode();

3. Create Routes Component

Create Routes.razor in your Components folder:

@using Blazouter.Models
@using Blazouter.Components

<Router Routes="@_routes" DefaultLayout="typeof(Layout.MainLayout)">
    <NotFound>
        <h1>404 - Page Not Found</h1>
    </NotFound>
</Router>

@code {
    private List<RouteConfig> _routes = new()
    {
        new RouteConfig
        {
            Path = "/",
            Component = typeof(Pages.Home),
            Transition = RouteTransition.Fade
        },
        new RouteConfig
        {
            Path = "/users",
            Component = typeof(Pages.UserLayout),
            Children = new List<RouteConfig>
            {
                new RouteConfig 
                { 
                    Path = ":id", 
                    Component = typeof(Pages.UserDetail) 
                }
            }
        }
    };
}

4. Use in App.razor

<Routes @rendermode="InteractiveServer" />

Important: The @rendermode="InteractiveServer" attribute is required to enable SignalR connection and interactivity in Blazor Server applications (.NET 8+). Without this attribute, pages will render statically but interactive features (navigation, buttons, etc.) will not work.

5. Include CSS

Add to your App.razor:

<link rel="stylesheet" href="@Assets["_content/Blazouter/blazouter[.min].css"]" />

Server-Specific Features

AddBlazouterSupport Extension

The AddBlazouterSupport() extension method:

  • Registers Blazouter endpoints
  • Configures server-side routing
  • Enables proper route resolution in server mode

Layouts

Set a default layout for all routes and override per route as needed:

<Router Routes="@_routes" DefaultLayout="typeof(Layout.MainLayout)">
    <NotFound><h1>404</h1></NotFound>
</Router>

@code {
    private List<RouteConfig> _routes = new()
    {
        // Uses DefaultLayout (MainLayout)
        new RouteConfig 
        { 
            Path = "/", 
            Component = typeof(Pages.Home) 
        },
        
        // Override with different layout
        new RouteConfig 
        { 
            Path = "/admin", 
            Component = typeof(Pages.Admin),
            Layout = typeof(Layout.AdminLayout)
        },
        
        // No layout for this route (e.g., for printing)
        new RouteConfig 
        { 
            Path = "/print", 
            Component = typeof(Pages.Print),
            Layout = null
        }
    };
}

Nested Routes in Server Mode

Use <RouterOutlet /> in parent components to render child routes:


@using Blazouter.Components

<div class="user-layout">
    <h1>Users Section</h1>
    <nav>
        <RouterLink Href="/users">All Users</RouterLink>
    </nav>
    <RouterOutlet />
</div>

Note: <RouterOutlet /> is for nested routing within a component hierarchy, while Layout (via DefaultLayout or RouteConfig.Layout) wraps entire routes with a common layout structure like headers, footers, and navigation.

Route Guards

new RouteConfig
{
    Path = "/admin",
    Component = typeof(AdminPanel),
    Guards = new List<Type> { typeof(AuthGuard) }
}

public class AuthGuard : IRouteGuard
{
    private readonly AuthenticationStateProvider _authProvider;
    
    public AuthGuard(AuthenticationStateProvider authProvider)
    {
        _authProvider = authProvider;
    }

    public async Task<bool> CanActivateAsync(RouteMatch match)
    {
        var authState = await _authProvider.GetAuthenticationStateAsync();
        return authState.User.Identity?.IsAuthenticated ?? false;
    }

    public Task<string?> GetRedirectPathAsync(RouteMatch match)
    {
        return Task.FromResult<string?>("/login");
    }
}

Programmatic Navigation

@inject RouterNavigationService NavService

private void GoToPage()
{
    NavService.NavigateTo("/users/123");
}

Performance Tips for Server Mode

  1. Enable lazy loading for large components
  2. Use route guards to protect expensive operations
  3. Configure transitions appropriately for server latency
  4. Use RouterOutlet for nested routes to improve rendering performance

Target Frameworks

  • .NET 8.0
  • .NET 9.0
  • .NET 10.0

Example Application

See the sample application for a complete working example.

Documentation

Migration from Standard Blazor Routing

Blazouter maintains compatibility while adding powerful features:

Blazor Router Blazouter
No guards Built-in IRouteGuard
No transitions Built-in transitions
Limited nesting Full nested route support
@page "/path" RouteConfig with Path = "/path"
NavigationManager RouterNavigationService (enhanced)

License

MIT License - see LICENSE for details.

Support

Made with ❤️ for the Blazor community

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.13 168 12/23/2025
1.0.12 213 11/25/2025
1.0.11 185 11/23/2025
1.0.10 400 11/19/2025
1.0.9 396 11/18/2025
1.0.8 222 11/16/2025
1.0.7 227 11/16/2025
1.0.6 233 11/16/2025
1.0.5 142 11/16/2025