Blazouter is a comprehensive routing library for Blazor applications, available as multiple specialized packages to support different hosting models.
| Package | Purpose | Platforms |
|---|---|---|
| Blazouter | Core routing library with all base features | All Blazor platforms |
| Blazouter.Server | Server-side rendering optimizations | Blazor Server / Blazor Web App (server project) |
| Blazouter.Hybrid | Native mobile/desktop support | .NET MAUI (iOS, Android, macOS, Windows) |
| Blazouter.WebAssembly | Client-side optimizations | Blazor WebAssembly / Blazor Web App (client project) |
Note: The
Blazouter.Webpackage has been deprecated. For Blazor Web Applications, useBlazouter.Serverfor the server project andBlazouter.WebAssemblyfor the client project.
- Tested and verified working
- Full hierarchical route structure support
- Example:
/users(parent) →/users/:id(child) - Unlimited nesting depth for complex route hierarchies
- Parent routes with child routes using
RouterOutletcomponent
- Tested and verified working
- Can abort navigation or redirect to different paths
IRouteMiddlewareinterface for custom middlewareInvokeAsyncmethod with context and next delegate- Pipeline execution pattern for before/after navigation logic
- Middleware execute before guards in the navigation pipeline
- Support for multiple middleware per route (executed in order)
- Data sharing between middleware and components via context.Data
- Middleware can be registered via dependency injection or created via Activator
- Common use cases: logging, analytics, performance monitoring, data preloading, feature flags
- Example middleware: LoggingMiddleware, TimingMiddleware, AnalyticsMiddleware, DataPreloadMiddleware
- Tested and verified working
CanActivateAsyncmethod to control route accessGetRedirectPathAsyncfor redirect on denied access- Example:
SampleAuthGuardin the sample application - Support for multiple guards per route (executed in order)
- Guards execute after middleware in the navigation pipeline
IRouteGuardinterface for custom authentication/authorization logic- Guards can be registered via dependency injection or created via Activator
- Reduces initial bundle size
- Tested and verified working
- Async component loading with
Task<Type> - Example: Lazy page with simulated 1-second delay
- Component caching after first load for performance
ComponentLoaderfunction property onRouteConfig- Loading state support with
<Loading>parameter in Router - WASM RCL Assembly Lazy Loading: Load entire Razor Class Library assemblies on demand
OnNavigateAsynccallback on Router for intercepting navigation and loading assembliesAdditionalAssembliesparameter for registering dynamically loaded assemblies for route discoveryBlazouterNavigationContextmodel withPathandCancellationTokenproperties- Cancellation support for in-flight callbacks during rapid navigation
- Path-based deduplication preventing redundant invocations
- Works with
LazyAssemblyLoaderand<BlazorWebAssemblyLazyLoad>in project files
- 14 built-in transition types
- Tested and verified working
- Custom animations can be added via CSS
- Configurable per-route via
Transitionproperty - Automatic animation application on route change
- GPU-accelerated animations for smooth performance
- Respects prefers-reduced-motion accessibility preference
- Built-in transitions:
None,Pop,Blur,Fade,Flip,Lift,Scale,Slide,Swipe,Reveal,Rotate,Curtain,SlideUp,SlideFade,Spotlight
- Query parameter support
- Browser history integration
NavigateTo(path)method- Tested and verified working
- Support for relative and absolute navigation
- Integration with Blazor's
NavigationManager RouterNavigationServicefor imperative navigation
- Tested and verified working
- Parameter change notifications
- Type-safe parameter extraction
- Query string parameter support
- Support for nested route parameters
- Path parameters using
:paramNamesyntax - Easy access via
RouterStateService.GetParam(key)
Exactmatching option- Tested and verified working
- Visual feedback for current route
- Supports nested route active states
- Automatic update on route changes
ActiveClassproperty for custom stylingRouterLinkcomponent with automatic active class
- Tested and verified working
- Layout state preservation during navigation
- Seamless layout switching during navigation
- Support for no-layout routes by setting Layout to null
RouteConfig.Layoutproperty for route-specific layoutsRouter.DefaultLayoutparameter for application-wide layout- Layout priority: Route.Layout > Router.DefaultLayout > No Layout
- Automatic layout wrapping using @Body from LayoutComponentBase
- Tested and verified working
- Mix programmatic and attribute-based routes
- Declarative route configuration using attributes
- Full documentation in ATTRIBUTE_ROUTING.md
- Automatic route discovery via assembly scanning
AddAttributeRoutes()extension for easy integrationFromAttributes()for pure attribute-based configuration- 9 attribute types:
[Route],[RouteMiddleware],[RouteGuard],[RouteTransition],[RouteLayout],[RouteTitle],[RouteData],[RouteRedirect],[RouteExact]
- Error event notifications
- Comprehensive error handling system
- Retry mechanism for failed operations
DefaultRouterErrorHandlerwith built-in loggingRouterErrorContextwith detailed error informationErrorContentparameter in Router for custom error UIIRouterErrorHandlerinterface for custom error handlers- Custom error handler registration via
AddBlazouterErrorHandler<T>() - Error types:
ComponentLoadFailed,GuardRejected,NavigationFailed,InvalidRoute,MiddlewareExecution
- Tested and verified working
- Type-safe query string manipulation with fluent API
- Automatic URL encoding via
Uri.EscapeDataString QueryStringBuilderclass for building query strings- Safe parsing with
TryParseand default value support - Comprehensive XML documentation with code examples
RouterStateExtensionsfor typed query parameter parsingHasQuery()to check parameter existenceGetAllQueryParams()to retrieve all parameters as dictionary- Nullable variants:
GetQueryIntOrNull(),GetQueryBoolOrNull(), etc. GetQueryBool()supporting "true", "false", "1", "0", "yes", "no", "on", "off"GetQueryDateTime(),GetQueryGuid(),GetQueryEnum<T>()for complex typesGetQueryInt(),GetQueryLong(),GetQueryDecimal(),GetQueryDouble()with default values
- 15
Set()method overloads for replacing values without duplicates RouterNavigationExtensionsfor enhanced navigation with query stringsNavigateToWithQuery()- Fluent query builder integrationNavigateToWithClearedQuery()- Clear all query parametersNavigateToWithRemovedQuery()- Remove specific parametersNavigateToWithReplacedQuery()- Replace all query parametersNavigateToWithSingleQuery()- Convenience for single parameterNavigateToWithUpdatedQuery()- Update specific parameters, preserve others
- Sample application demonstrates all features in Navigation.razor and UserList.razor
- 15
Add()method overloads for all common types (string, int, long, decimal, double, bool, DateTime, Guid, enum, and nullable variants)
- Tested and verified working
- Type-safe JavaScript modules with
.d.tsdefinition files for IntelliSense - Comprehensive browser API integration with 5 specialized interop services
- Automatic TypeScript compilation to JavaScript with source maps
- Global namespace exposure pattern (
window.blazouterNavigation,window.blazouterDocument,window.blazouterStorage,window.blazouterViewport,window.blazouterClipboard) - Optional service registration via
AddBlazouterInterop() NavigationInteropservice for History API access- Navigate back/forward/go in browser history
- URL and path information (getCurrentUrl, getPathname)
- Hash navigation (getHash, setHash)
- Query parameter helpers (getQueryString, getQueryParam, getAllQueryParams)
- Page reload functionality
- Check navigation availability
- Manage history state (push and replace entries)
DocumentInteropservice for document manipulation- Dynamic title updates
- Meta tag management (description, keywords, Open Graph tags)
- Canonical URL support for SEO
- Scroll position tracking (getScrollPosition, setScrollPosition)
- Scroll to top/element with smooth scrolling
- Element visibility detection (isElementVisible)
- CSS class manipulation (addClass, removeClass, toggleClass)
- Document ready state checks
- Element focus management
StorageInteropservice for browser storage- Complete localStorage operations (set, get, remove, clear, keys, has)
- Complete sessionStorage operations (set, get, remove, clear, keys, has)
- Generic type support with JSON serialization
- Type-safe storage access for complex objects
ViewportInteropservice for viewport and device info- Viewport dimensions (getViewportSize, width, height)
- Screen information (getScreenSize)
- Device pixel ratio detection
- Orientation detection (isPortrait, isLandscape, getOrientation)
- Device type detection (isMobile, isTablet, isDesktop, getDeviceType)
- Fullscreen API (isFullscreen, requestFullscreen, exitFullscreen)
ClipboardInteropservice for clipboard operations- Copy text to clipboard with fallback for older browsers
- Read text from clipboard
- Feature detection (isClipboardSupported)
- Permission checks (hasClipboardReadPermission, hasClipboardWritePermission)
- Integration with
RouterNavigationServiceGoBackAsync()- True browser back navigationGoForwardAsync()- Browser forward navigationCanGoBackAsync()- Check if back navigation is available
- Requires JavaScript module import:
<script type="module" src="_content/Blazouter/js/index.js"></script> - Full documentation in TYPESCRIPT_INTEGRATION.md
- Comprehensive demo page in WebAssembly sample at
/typescript-demoshowcasing all 5 interop services
Main routing component that:
- Applies transitions
- Handles lazy loading
- Executes route guards
- Matches current URL to route configuration
- Renders matched components with optional layouts
- Manages layout wrapping via DefaultLayout parameter
- Supports
OnNavigateAsynccallback for WASM assembly lazy loading - Supports
AdditionalAssembliesfor dynamically loaded assembly route discovery
Navigation link component that:
- Supports exact matching
- Applies active class to current route
- Renders anchor tags with proper href
- Handles click events for SPA navigation
Nested route renderer that:
- Supports transitions
- Maintains route hierarchy
- Displays child route components
- Registered as scoped service
- Route priority and exact match handling
- Dynamic parameter extraction from URL paths
- Query string parsing and parameter extraction
- Pattern matching for routes with wildcard support
- Nested route matching with parent-child relationships
- Query parameter retrieval
- Registered as scoped service
- Component lifecycle integration
- Event notifications for route changes
- Current route tracking with RouteMatch
- Parameter access via GetParam(key) method
- Central state management for routing context
- Browser history integration
- Registered as scoped service
- Support for relative and absolute navigation
- Query parameter handling and URL building
- Programmatic navigation API with NavigateTo(path)
- Wrapper around NavigationManager for enhanced functionality
- Async methods for browser navigation: GoBackAsync(), GoForwardAsync(), CanGoBackAsync()
- Registered as scoped service via AddBlazouterInterop()
- Type-safe access to browser History API
- Navigate back and forward in history
- Check history length and navigation availability
- Manage history state (push, replace, get)
- Requires JavaScript module import for functionality
- Used by RouterNavigationService async navigation methods
- Registered as scoped service via AddBlazouterInterop()
- Type-safe document and DOM manipulation
- Dynamic page title updates
- Meta tag management (description, keywords, Open Graph)
- Canonical URL support for SEO
- Scroll management (scroll to top, scroll to element)
- Element focus management
- Requires JavaScript module import for functionality
- Supports all 8 route attributes
- Reflection-based with trimming warnings
- Converts attributes to RouteConfig objects
- Static service for route discovery at startup
- Discovers components with [Route] attribute
- Assembly scanning for attribute-based routes
- Error type categorization
- Retry mechanism support
- Default handler with console logging
- Error context with detailed information
- Error handling interface for custom implementations
- Registered as scoped service via AddBlazouterErrorHandler()
- Fluent API for building query strings
- Support for nullable variants of all types
AddIf()for conditional parameter additionAddRange()for multiple values per parameterBuild()returns query string without?prefixRemove()andClear()for parameter removal- 15 type-safe
Set()methods for replacing values - Automatic URL encoding with Uri.EscapeDataString
- 15 type-safe
Add()methods for appending values BuildWithPrefix()returns query string with?prefixToDictionary()converts to Dictionary<string, string>- Support for string, int, long, decimal, double, bool, DateTime, Guid, enum types
HasQuery()- Check if parameter existsGetQueryBoolOrNull()- Parse nullable boolean- All methods use InvariantCulture for consistent parsing
GetAllQueryParams()- Get all parameters as dictionaryGetQueryArray()- Get multiple values for same parameterGetQueryGuid(),GetQueryGuidOrNull()- Parse Guid parametersGetQueryEnum<T>(),GetQueryEnumOrNull<T>()- Parse enum parametersGetQueryDateTime(),GetQueryDateTimeOrNull()- Parse DateTime in ISO 8601 formatGetQueryBool()- Parse boolean with support for "true", "false", "1", "0", "yes", "no", "on", "off"GetQueryInt(),GetQueryLong(),GetQueryDecimal(),GetQueryDouble()- Parse numeric parameters with defaultsGetQueryIntOrNull(),GetQueryLongOrNull(),GetQueryDecimalOrNull(),GetQueryDoubleOrNull()- Parse nullable numeric parameters
NavigateToWithClearedQuery()- Clear all query parametersNavigateToWithQuery()- Navigate with fluent query builderNavigateToWithReplacedQuery()- Replace all query parametersNavigateToWithRemovedQuery()- Remove specific parameters by keyNavigateToWithSingleQuery()- Convenience method for single string parameterNavigateToWithSingleQuery<T>()- Convenience method for single typed parameterNavigateToWithUpdatedQuery()- Update specific parameters while preserving others
Exact: Exact path matching flag - When true, requires exact URL matchData: Custom data dictionary - Arbitrary metadata passed to componentsTransition: Animation type - One of 14 built-in RouteTransition enum valuesHasExplicitLayout: Internal flag - Tracks if Layout was explicitly set (even if null)Layout: Layout component type - Overrides DefaultLayout, set to null for no layoutPath: Route pattern (e.g., "/users/:id") - Supports dynamic parameters with:prefixTitle: Route title for metadata - Used for page title, breadcrumbs, or navigation labelsChildren: Nested route configurations - List of child RouteConfig for hierarchical routingRedirectTo: Redirect path - Automatically redirects to specified path when route matchesComponent: Component type to render - Direct component reference for immediate loadingGuards: List of route guard types - Array of IRouteGuard implementations for access controlComponentLoader: Async component loader for lazy loading - ReturnsTask<Type>for on-demand loadingMiddleware: List of route middleware types - Array of IRouteMiddleware implementations for cross-cutting concerns
- Lazy loading support with ComponentLoader
- 14 transition types with RouteTransition enum
- Comprehensive XML documentation for IntelliSense
- Layout system support (DefaultLayout, per-route Layout)
- Fluent query string building with automatic URL encoding
- CSS animations included (blazouter.css, blazouter.min.css)
- All routing components (Router, RouterLink, RouterOutlet)
- Multi-framework support (net6.0, net7.0, net8.0, net9.0, net10.0)
- Type-safe query parameter parsing with 15+ extension methods
- Navigation services (RouterNavigationService, RouterStateService)
- Route guards interface (IRouteGuard, AuthGuard base implementation)
- Route configuration and matching (RouteConfig, RouteMatcherService)
- Attribute-based routing (RouteAttributeDiscoveryService, 8 route attributes)
- Error handling (IRouterErrorHandler, DefaultRouterErrorHandler, RouterErrorContext)
- Query string utilities (QueryStringBuilder, RouterStateExtensions, RouterNavigationExtensions)
- Server-side route optimization
- Framework references for ASP.NET Core
- Enhanced performance for server scenarios
AddBlazouterSupport()extension for endpoint mapping
- SPA navigation support
- Browser platform support
- Client-side route optimization
- Browser-specific enhancements
- Reduced bundle size optimizations
- Native navigation integration
- MAUI-specific routing features
- Native mobile/desktop integration
- Platform-specific optimizations for iOS, Android, macOS, Windows
The sample application demonstrates:
- Protected page with route guard
- Home page with feature overview
- About page with library information
- Lazy loaded page with component loader
- Users page with nested routing (list and detail views)
- Navigation page with comprehensive query string utilities showcase
- Type-safe query parameter parsing examples
- Traditional vs fluent query string building comparison
- Query parameter manipulation (update, remove, clear)
- Interactive buttons demonstrating all query string features
- Lazy-loaded RCL assembly pages (Support, Help) via
OnNavigateAsyncandAdditionalAssemblies- Demonstrates loading
Blazouter.LazyModule.Sampleassembly on demand - Uses
LazyAssemblyLoaderwith<BlazorWebAssemblyLazyLoad>configuration
- Demonstrates loading
All features are interactive and can be tested by navigating through the application.
| Feature | Traditional Blazor | Blazouter |
|---|---|---|
| Transitions | ❌ None | ✅ 14 built-in transitions |
| Active Links | ✅ Automatic with RouterLink | |
| Lazy Loading | ✅ ComponentLoader + WASM RCL assembly lazy loading | |
| Route Guards | ❌ Manual | ✅ Built-in IRouteGuard interface |
| Layout System | ✅ Dynamic per-route with priority | |
| Error Handling | ❌ Manual | ✅ Built-in with IRouterErrorHandler |
| Nested Routes | ❌ Limited | ✅ Unlimited nesting depth |
| Attribute Routes | ❌ @page only | ✅ 8 attribute types with full config |
| Parameter Access | ✅ Basic | ✅ Enhanced with RouterStateService |
| Programmatic Nav | ✅ Basic | ✅ Enhanced with RouterNavigationService |
| Query String Helpers | ❌ Manual parsing | ✅ Type-safe fluent API with 15+ methods |