Routeables.Blazor 2.1.0

dotnet add package Routeables.Blazor --version 2.1.0
                    
NuGet\Install-Package Routeables.Blazor -Version 2.1.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="Routeables.Blazor" Version="2.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Routeables.Blazor" Version="2.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Routeables.Blazor" />
                    
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 Routeables.Blazor --version 2.1.0
                    
#r "nuget: Routeables.Blazor, 2.1.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 Routeables.Blazor@2.1.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=Routeables.Blazor&version=2.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Routeables.Blazor&version=2.1.0
                    
Install as a Cake Tool

Routeables.Blazor

The Blazor host of Routeables: Blazor Server, Blazor WebAssembly and MAUI Blazor Hybrid. It plugs the router into Razor components and keeps the browser address in step with it. Targets .NET 10.

dotnet add package Routeables.Blazor

The package brings Routeables (routing, abstractions and the source generator): there is nothing else to add.

Set up

services.UseRouteablesServer();      // or UseRouteablesWebAssembly, UseRouteablesHybrid

An application with a menu gives its menu view model: services.UseRouteablesServer<MainViewModel>();.

Everything is scoped, so each Blazor Server circuit has its own history, and so has its menu. Nothing is discovered for you: the menu view model and the routes are what you give.

A view

@* samples/XAnimals.Razor/Components/Animals/DogDetailView.razor *@
@inherits RouteableFor<DogDetailView, DogDetailViewModel>

<AnimalDetail ViewModel="ViewModel" />

RouteableFor<TView, TViewModel> gives the typed ViewModel and the lifecycle hooks. A zone that shows a region is <RouteableRegion Region="shell-content" />.

The layout

A layout inherits RouteableMainLayoutBase: it follows the current view, the lock and the theme. The ready-made RouteableMainLayout comes with the dialogs and notifications.

<RouteableMenu /> is the menu of the layout as a component of its own: one button per entry of the menu view model, the current one marked, the locked ones disabled (Closed, Class and Label are its parameters). Put it in a layout of your own the same way.

For a route declared with an explicit address (/customers/{id:int}), the browser address and the router stay in step: a route change updates the address, a typed address or the browser's back button route the router, and a refused change puts the address back.

Who decides the route: Routeables. The package ships Main.razor, whose two @page routes (/ and /{*path}) only give the Blazor router a page for every address so that it never shows NotFound; it draws nothing, and the layout shows the current view of the Routeables router. Declare the routes of the application on its view models ([Routeable("about")]) or with RegisterRoute, not with @page: a page of your own with an @page is rendered by Blazor, outside the router, and neither its history nor its guards apply to it. A layout of your own can use NavLink with the route as href, since the address follows the route.

Dialogs, modals and notifications

Drawn with plain Razor (Routeables.Blazor.Services namespace). UseRouteablesServer (and UseRouteablesWebAssembly, UseRouteablesHybrid) already registers them; call UseRouteablesServices yourself only to move the notifications, to replace a service or to draw the dialogs with another IMessageBoxService:

services.UseRouteablesServer<MainViewModel>();
services.UseRouteablesServices(position: RouteableNotificationPosition.TopRight, maxDisplayed: 3);   // optional

Everything is scoped. There is one IRouteableDialogService (message boxes, content dialogs and task dialogs): it asks an IMessageBoxService to draw them, DefaultMessageBoxService (plain Razor, shown by the hosts) unless UseRouteablesServices(messageBoxService: sp => ...) gives another one; Reshapes.Blazor.MudBlazor gives the MudBlazor one. The notification service has an optional factory too.

  • The hosts that draw the services: RouteableDialogHost, RouteableContentDialogHost, RouteableTaskDialogHost, RouteableModalHost, RouteableNotificationHost. The default RouteableMainLayout already contains them; a layout of your own inherits RouteableMainLayoutBase and adds them.
  • RouteableModalFor<TView, TViewModel, TResult>: shows a view in a modal and returns a typed result when its view model closes.
  • NotFound, the default page for an unknown address.

Contracts: Routeables.Services.

Good to know

  • A component must be safe to dispose twice: the router disposes pages that leave its history, and Blazor disposes what it renders.
  • The first time a page is shown, Blazor renders the very instance the router created, so the hooks of the view run on the displayed component. When the page comes back from the history, Blazor builds another instance: keep the state that a hook reads in the view model. See the Blazor guide.
  • A Transient service that is IDisposable lives until the circuit ends: register it Scoped or Singleton. See lifecycle.
  • MudBlazor flavour: Reshapes.

Next

Routeables for Blazor developers, hosts guide, samples samples/XAnimals.Razor and the Blazor Server and WebAssembly heads.

Product Compatible and additional computed target framework versions.
.NET 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 (1)

Showing the top 1 NuGet packages that depend on Routeables.Blazor:

Package Downloads
Reshapes.Blazor.MudBlazor

MudBlazor dialogs for Routeables: message boxes, content dialogs, task dialogs and notifications drawn with MudBlazor.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.1.0 214 11/11/2026