Blazouter 1.0.2

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Blazouter --version 1.0.2
                    
NuGet\Install-Package Blazouter -Version 1.0.2
                    
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" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Blazouter" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Blazouter" />
                    
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 --version 1.0.2
                    
#r "nuget: Blazouter, 1.0.2"
                    
#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@1.0.2
                    
#: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&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Blazouter&version=1.0.2
                    
Install as a Cake Tool

Blazouter 🚀

NuGet NuGet Downloads CI Build License: MIT

A powerful React Router-like routing library for Blazor applications. Blazouter brings the best features of React Router to the Blazor ecosystem.

🌟 Why Blazouter?

Blazor's built-in routing is functional but lacks many modern features that developers expect from frameworks like React Router. Blazouter fills this gap by providing:

  • True nested routing - Not just @page directives
  • Built-in route guards - Protect your routes easily
  • Lazy loading - Load components on-demand
  • Beautiful transitions - Smooth animations between routes
  • Type-safe - Full IntelliSense support
  • Programmatic navigation - Navigate imperatively with ease

✨ Features

Blazouter addresses the limitations of traditional Blazor routing:

Feature React Router Blazor Router Blazouter
Nested Routes ✔ Easy to define child routes ❌ Limited, single level with @page ✅ Full support
Dynamic Params ✔ Easy route parameters ✔ Available but basic ✅ Enhanced with easy access
Lazy Loading ✔ Route-based code splitting ❌ Still limited in WASM ✅ Full support
Route Guards ✔ Easy with wrappers/hooks ❌ Manual, component-based ✅ Built-in guard system
Programmatic Navigation navigate("/path") NavigationManager.NavigateTo ✅ Enhanced navigation service
Route Transitions ✔ Very easy ❌ No native support ✅ Built-in transitions
Conditional Rendering ✔ Direct with <Route> ❌ Manual via state ✅ Component-based

Key Features

  • 🎯 Nested Routes: Define complex hierarchical route structures easily
  • 🔒 Route Guards: Protect routes with authentication and authorization logic
  • ⚡ Lazy Loading: Load components on-demand for better performance
  • 🎨 Route Transitions: Beautiful animations when navigating between routes
  • 🔗 Programmatic Navigation: Navigate imperatively with enhanced navigation service
  • 📊 Route Parameters: Easy access to route and query parameters
  • 🎭 Dynamic Components: Load components dynamically based on routes

🚀 Quick Start

Installation

dotnet add package Blazouter

Setup

  1. Add Blazouter services in Program.cs:
using Blazouter.Extensions;

builder.Services.AddBlazouter();
  1. Define routes in App.razor:
@using Blazouter.Components
@using Blazouter.Models

<Blazouter.Components.Router Routes="@_routes">
    <NotFound>
        <h1>404 - Page Not Found</h1>
    </NotFound>
</Blazouter.Components.Router>

@code {
    private List<RouteConfig> _routes = new()
    {
        new RouteConfig
        {
            Path = "/",
            Component = typeof(Pages.Home),
            Transition = "fade"
        },
        new RouteConfig
        {
            Path = "/users",
            Component = typeof(Pages.UserLayout),
            Children = new List<RouteConfig>
            {
                new RouteConfig 
                { 
                    Path = ":id", 
                    Component = typeof(Pages.UserDetail) 
                }
            }
        }
    };
}
  1. Include the CSS in your index.html:
<link rel="stylesheet" href="_content/Blazouter/blazouter.css" />

📖 Usage Examples

Basic Routing

new RouteConfig
{
    Path = "/about",
    Component = typeof(About),
    Title = "About Us",
    Transition = "slide"
}

Nested Routes

new RouteConfig
{
    Path = "/products",
    Component = typeof(ProductLayout),
    Children = new List<RouteConfig>
    {
        new RouteConfig 
        { 
            Path = "", 
            Component = typeof(ProductList),
            Exact = true 
        },
        new RouteConfig 
        { 
            Path = ":id", 
            Component = typeof(ProductDetail) 
        }
    }
}

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

@using Blazouter.Components

<div class="layout">
    <h1>Products</h1>
    <RouterOutlet />
</div>

Route Guards (Protected Routes)

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

Create a guard:

using Blazouter.Guards;
using Blazouter.Models;

public class AuthGuard : IRouteGuard
{
    public async Task<bool> CanActivateAsync(RouteMatch match)
    {
        // Check authentication
        return await IsAuthenticated();
    }

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

Lazy Loading

new RouteConfig
{
    Path = "/reports",
    ComponentLoader = async () =>
    {
        // Simulate loading delay or dynamic import
        await Task.Delay(100);
        return typeof(ReportsPage);
    }
}
@using Blazouter.Components

<nav>
    <RouterLink Href="/" Exact="true" ActiveClass="active">Home</RouterLink>
    <RouterLink Href="/about" ActiveClass="active">About</RouterLink>
    <RouterLink Href="/users" ActiveClass="active">Users</RouterLink>
</nav>

Programmatic Navigation

@inject RouterNavigationService NavService

<button @onclick="NavigateToUser">Go to User</button>

@code {
    private void NavigateToUser()
    {
        NavService.NavigateTo("/users/123");
    }
}

Access Route Parameters

@using Blazouter.Services
@inject RouterStateService RouterState

<h1>User: @_userId</h1>

@code {
    private string? _userId;

    protected override void OnInitialized()
    {
        _userId = RouterState.GetParam("id");
    }
}

🎨 Route Transitions

Blazouter includes built-in transitions:

  • fade - Fade in animation
  • slide - Slide from left animation
  • slide-up - Slide from bottom animation
  • scale - Scale in animation
new RouteConfig
{
    Path = "/",
    Component = typeof(Home),
    Transition = "fade"
}

🏗️ Project Structure

Blazouter/
├── src/
│   └── Blazouter/                 # Main library
│       ├── Components/            # Router components
│       │   ├── Router.razor
│       │   ├── RouterLink.razor
│       │   └── RouterOutlet.razor
│       ├── Guards/                # Route guard interfaces
│       ├── Models/                # Route models
│       ├── Services/              # Routing services
│       └── wwwroot/              # CSS and assets
└── samples/
    └── Blazouter.Sample/          # Sample application

🎮 Running the Sample

To see Blazouter in action:

cd samples/Blazouter.Sample
dotnet run

Then navigate to https://localhost:5001 in your browser.

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📄 License

This project is licensed under the MIT License.

📊 Project Stats

  • Supported .NET versions: .NET 6.0, 7.0, 8.0, 9.0, 10.0
  • Platform: Blazor WebAssembly & Blazor Server
  • License: MIT
  • Package: NuGet

🙏 Acknowledgments

Inspired by React Router and built to bring similar capabilities to the Blazor ecosystem.

📝 Roadmap

  • Query string helpers and utilities
  • Route middleware support
  • Better TypeScript integration for JS interop
  • Advanced caching strategies
  • Performance optimizations

⭐ Show Your Support

If you find Blazouter helpful, please consider giving it a star on GitHub! It helps the project grow and reach more developers.


Made with ❤️ for the Blazor community

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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 (4)

Showing the top 4 NuGet packages that depend on Blazouter:

Package Downloads
Blazouter.WebAssembly

WebAssembly-specific extensions for Blazouter routing library. This package provides optimized components and integration for Blazor WebAssembly applications with client-side routing enhancements. Enables React Router-like routing features in Blazor WASM with full support for nested routes, route guards, lazy loading, smooth transitions, and programmatic navigation. Optimized for reduced bundle size and fast client-side performance.

Blazouter.Hybrid

Blazor Hybrid/MAUI-specific extensions for Blazouter routing library. This package provides optimized components and integration for Blazor Hybrid applications running on .NET MAUI. Enables React Router-like routing features in native mobile and desktop apps with full support for nested routes, route guards, lazy loading, smooth transitions, and programmatic navigation. Includes platform-specific optimizations for iOS, Android, macOS, and Windows.

Blazouter.Server

Server-side specific extensions for Blazouter routing library. This package provides the necessary components and integration for Blazor Server applications, including AddBlazouterSupport extension method. Enables React Router-like routing features in Blazor Server mode with full support for nested routes, route guards, lazy loading, smooth transitions, and programmatic navigation.

Blazouter.Web

Web App specific extensions for Blazouter routing library. This package provides the necessary components and integration for Blazor Web App applications (.NET 8+) that support both Server and WebAssembly render modes (Auto/Interactive). Enables React Router-like routing features in the unified Blazor Web App model with full support for nested routes, guards, lazy loading, and smooth transitions. Works seamlessly with InteractiveServer, InteractiveWebAssembly, and InteractiveAuto render modes.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.13 263 12/23/2025
1.0.12 400,532 11/25/2025
1.0.11 247 11/23/2025
1.0.10 465 11/19/2025
1.0.9 443 11/18/2025
1.0.8 281 11/16/2025
1.0.7 267 11/16/2025
1.0.6 275 11/16/2025
1.0.5 178 11/16/2025
1.0.2 179 11/15/2025
1.0.1 181 11/15/2025
1.0.0 189 11/15/2025

v1.0.2
           - Type-safe RouteTransition enum
           - Enhanced sample application with comprehensive demos
           - Fixed component re-rendering on parameter changes
           - Loading state for lazy-loaded routes
           - Professional UI/UX improvements
           - Full documentation and examples