ReactorRouter 0.3.0

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

ReactorRouter

NuGet NuGet Downloads

ReactorRouter is a lightweight routing library for .NET MAUI Reactor applications. It provides a declarative way to handle navigation, nested routes, and route transitions.

Features

  • Declarative Routing: Define your route hierarchy in a single place.
  • Nested Routes: Supports deeply nested layouts with Outlet.
  • Transitions: Built-in support for page transitions (Fade, Slide, etc.).
  • Navigation: Simple API for programmatic navigation.

Installation

Add the ReactorRouter project or NuGet package to your MAUI solution.

Getting Started

1. Define Routes & Initialize

ReactorRouter supports two ways to configure your routes: using the App Builder (cleaner, recommended for larger apps) or the Component API (quick start).

Configure routes in MauiProgram.cs. This keeps your routing logic centralized and separate from your UI code.

MauiProgram.cs

var builder = MauiApp.CreateBuilder();
builder
    .UseMauiReactorApp<App>()
    .UseReactorRouter(r =>
    {
        r.Routes(
            new RouteDefinition("/", typeof(RootLayout),
                new RouteDefinition("dashboard", typeof(DashboardLayout),
                    RouteDefinition.Index(typeof(HomePage)),
                    new RouteDefinition("settings", typeof(SettingsPage))
                        { Transition = TransitionType.SlideLeft }
                ),
                new RouteDefinition("login", typeof(LoginPage))
                    { Transition = TransitionType.Fade },
                new RouteDefinition("*", typeof(NotFoundPage)) // Fallback
            )
        );
        r.InitialPath("/dashboard");
    })
    .Build();

App.cs Then, simply instantiate Router without arguments in your main component.

class App : Component
{
    public override VisualNode Render()
        => ContentPage(new Router());
}
Option B: Component API (Quick Start)

Define routes directly in your main component using the fluent API.

// Define routes
private static readonly RouteDefinition[] Routes =
[
    new RouteDefinition("/", typeof(RootLayout),
        new RouteDefinition("dashboard", typeof(DashboardLayout),
            RouteDefinition.Index(typeof(HomePage)),
            new RouteDefinition("settings", typeof(SettingsPage))
        ),
        new RouteDefinition("login", typeof(LoginPage)),
        new RouteDefinition("*", typeof(NotFoundPage))
    )
];

// Initialize in Render
class MainPage : Component
{
    public override VisualNode Render()
        => ContentPage(
            new Router()
                .Routes(Routes)
                .InitialPath("/dashboard")
        );
}

2. Use Outlet for Nested Content

In your layout components (like RootLayout or DashboardLayout), use Outlet to determine where child routes should be rendered.

class DashboardLayout : Component
{
    public override VisualNode Render()
        => Grid("50, *", "200, *",
            // Sidebar
            new Sidebar().GridRowSpan(2),

            // Top Bar
            new TopBar().GridColumn(1),

            // Content Area - Child routes render here
            new Outlet()
                .Transition(TransitionType.Fade)
                .Duration(300)
                .GridRow(1)
                .GridColumn(1)
        );
}

4. Navigation

You can navigate using the Link component or the NavigationService.

Using Link:

new Link().To("/dashboard/settings")
// Or with custom content
new Link().To("/login")
    .Child(Label("Go to Login"))

Programmatic Navigation:

NavigationService.Instance.NavigateTo("/profile/123");

Route Parameters

You can define parameters in your route path using :paramName and access query strings with ?key=value.

ReactorRouter supports two approaches for reading route/query parameters depending on how your component is structured.


Approach 1: [Param] IParameter<RouterContext> (Field Injection)

Use this when your component does not need a custom constructor. The RouterContext is injected automatically as a field parameter.

// Route definition
new RouteDefinition("profile/:userId", typeof(ProfilePage))

// Component
public partial class ProfilePage : Component
{
    [Param] IParameter<RouterContext> _ctx;

    public override VisualNode Render()
    {
        var userId = _ctx.Value.Params.GetOrDefault("userId", "unknown");
        var tab = _ctx.Value.Query.GetOrDefault("tab", "overview");
        // ...
    }
}

Approach 2: RouteHooks (Static API, Constructor-Friendly)

Use this when your component requires a custom constructor. Since [Param] is field-level injection and cannot be used inside a constructor, RouteHooks provides a static API that can be called anywhere ? including constructors.

// Route definition
new RouteDefinition("profile/:userId", typeof(ProfilePage))

// Component
public class ProfilePage : Component
{
    private readonly string _userId;
    private readonly string _tab;

    public ProfilePage()
    {
        _userId = RouteHooks.UseRouteParams().GetOrDefault("userId", "unknown");
        _tab = RouteHooks.UseRouteQuery().GetOrDefault("tab", "overview");
    }

    public override VisualNode Render()
    {
        // use _userId, _tab ...
    }
}

Which one should I use?

  • No custom constructor needed �� use [Param] IParameter<RouterContext> (less boilerplate)
  • Custom constructor required �� use RouteHooks (more flexible)

Conclusion

ReactorRouter simplifies routing in .NET MAUI applications, allowing developers to create intuitive navigation experiences with minimal effort. For more information, check the documentation.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-android35.0 is compatible.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-ios18.0 is compatible.  net9.0-maccatalyst was computed.  net9.0-maccatalyst18.0 is compatible.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net9.0-windows10.0.19041 is compatible.  net10.0 is compatible.  net10.0-android was computed.  net10.0-android36.0 is compatible.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-ios26.0 is compatible.  net10.0-maccatalyst was computed.  net10.0-maccatalyst26.0 is compatible.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed.  net10.0-windows10.0.19041 is compatible. 
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
0.4.0 41 4/5/2026
0.3.0 99 3/19/2026
0.2.0 83 3/18/2026
0.1.0 91 3/12/2026