This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Blazouter is a React Router-like routing library for Blazor applications. It provides nested routes, route guards, lazy loading, transitions, middleware, and programmatic navigation across all Blazor hosting models.
# Restore dependencies
dotnet restore Blazouter.sln
# Build entire solution
dotnet build Blazouter.sln
# Build in Release mode (as CI does)
dotnet build Blazouter.sln -c Release -p:UseSharedCompilation=false --no-restore
# Build a specific project
dotnet build src/Blazouter/Blazouter.csproj
# Run sample apps
dotnet run --project samples/Blazouter.Server.Sample/Blazouter.Server.Sample.csproj
dotnet run --project samples/Blazouter.WebAssembly.Sample/Blazouter.WebAssembly.Sample.csproj
dotnet run --project samples/Blazouter.Web.Sample/Blazouter.Web.Sample/Blazouter.Web.Sample.csprojThere are no tests in this repository. CI only runs dotnet build in Release mode on Windows.
global.jsonpins to .NET SDK 11.0.x (preview, with rollForward: latestMajor)- Core library (
Blazouter) multi-targets: net6.0, net7.0, net8.0, net9.0, net10.0 Blazouter.ServerandBlazouter.Webtarget: net8.0, net9.0, net10.0Blazouter.WebAssemblytargets: net6.0, net7.0, net8.0, net9.0, net10.0Blazouter.Hybridtargets: net9.0 and net10.0 (iOS, Android, macOS, Windows via MAUI)- All projects use
LangVersion=previewandNullable=enable
src/
├── Blazouter/ # Core library - all routing logic lives here
├── Blazouter.Server/ # Server extension: AddBlazouterSupport() for MapRazorComponents
├── Blazouter.WebAssembly/ # WebAssembly extension (thin wrapper)
├── Blazouter.Hybrid/ # MAUI extension: AddBlazouterSupport() for MauiAppBuilder
└── Blazouter.Web/ # DEPRECATED - use Server + WebAssembly instead
Platform packages (Server, WebAssembly, Hybrid, Web) are thin wrappers that reference the core Blazouter project. All meaningful routing logic is in the core package.
- Components/:
Router.razor,RouterOutlet.razor,RouterLink.razor- the Blazor components users place in their markup. Each has a.razor.cscode-behind. - Services/:
RouterStateService(singleton, global state),RouterNavigationService(scoped, per-circuit navigation),RouteMatcherService(route matching),CachedRouteMatcherService(decorator with LRU cache),RouteCacheService,RouteAttributeDiscoveryService - Interfaces/:
IRouteGuard,IRouteMiddleware,IRouteMatcherService,IRouterErrorHandler,IRouteCacheService - Models/:
RouteConfig,RouteMatch,CacheOptions,CacheStatistics,RouterErrorContext,RouterErrorInfo,RouteMiddlewareContext - Attributes/: 10 attribute types for declarative routing (
[Route],[RouteGuard],[RouteTitle],[RouteTransition],[RouteMiddleware],[RouteLayout],[RouteData],[RouteExact],[RouteRedirect],[RouteCache]) - Enums/:
RouteTransition(15 transition types),RouterErrorType - Extensions/:
ServiceCollectionExtensions(DI registration:AddBlazouter(),AddBlazouterInterop(),AddBlazouterErrorHandler<T>()), plus extensions for query strings, navigation, transitions, and cache - Interops/: JS interop wrappers -
NavigationInterop,DocumentInterop,StorageInterop,ViewportInterop,ClipboardInterop - Utilities/:
QueryStringBuilder- fluent API for query string construction - wwwroot/: CSS (
blazouter.css,blazouter.min.css) and compiled JS modules from TypeScript
// Core services
services.AddBlazouter(); // RouterStateService (singleton), RouterNavigationService (scoped), cached route matcher (singleton)
services.AddBlazouterInterop(); // Optional JS interop services (all scoped)
services.AddBlazouterErrorHandler<T>(); // Optional custom error handler (scoped)The core Blazouter project exposes internals to Blazouter.Web, Blazouter.Hybrid, Blazouter.Server, and Blazouter.WebAssembly.
All packages share the same version, currently 1.0.13. Version is set in each .csproj <Version> property. When bumping versions, update all 5 project files (Blazouter, Blazouter.Server, Blazouter.WebAssembly, Blazouter.Hybrid, Blazouter.Web).
- Indent: 4 spaces, CRLF line endings (enforced via
.editorconfig) - XML indent: 2 spaces
- PascalCase for types, properties, methods; interfaces prefixed with
I varusage is set tofalse(explicit types preferred) though this is silent severity- Block-scoped namespaces (
namespace X { }) - Expression-bodied members for accessors/properties/lambdas; not for constructors/methods
- XML documentation comments on all public APIs (
GenerateDocumentationFile=true, warning 1591 suppressed) - AOT/Trimming compatible: all projects enable trim analyzers, AOT analyzers, and are marked
IsAotCompatible
The CI build suppresses: CS0067, CS0108, CS0109, CS0114, CS0169, CS0414, CS0618, CS0649, CS8632, CA1416, NU5104, NETSDK1138, SYSLIB0003
Blazouter.Webis deprecated; Blazor Web Apps should useBlazouter.Server+Blazouter.WebAssembly- Route matching uses a decorator pattern:
CachedRouteMatcherServicewrapsRouteMatcherServicewith LRU caching RouterStateServiceis singleton (shared state),RouterNavigationServiceis scoped (per-circuit in Server mode)- The Router component auto-filters both middleware data and route data parameters to match only what the target component declares