Creating a Router
Define routes and create a router integration:Router Integration
Integrate the router with your app:Route Definitions
Basic Route
Route with Parameters
Route with Guard
Nested Routes
Navigation API
Router Context
Screens receive a context object:Router Components
Breadcrumb Navigation
Tab Navigation
Keybinding Integration
Bind routes to global shortcuts:History Management
Route Guards
Implement authentication and authorization:params— Route parametersstate— Current app statecontext— Navigation context (from, to, action)
true— Allow navigationfalse— Block navigation{ redirect, params }— Redirect to different route
Programmatic Navigation
Navigate from event handlers:Animated Route Transitions
Combine router with animations:Best Practices
Unique Route IDs
Use descriptive, unique route IDs. Avoid generic names like “detail” or “edit”. Prefer “user-detail” or “user-edit”.
Route Guards
Implement guards for authentication and authorization. Guards run before navigation, preventing unauthorized access.
History Depth
Set reasonable
maxDepth limits (10-50 entries). Unbounded history can consume memory in long-running apps.Nested Routes
Use nested routes for tabbed interfaces and multi-level navigation. The
outlet pattern keeps layouts clean.Next Steps
Graphics
Draw charts, images, and custom graphics
Performance
Optimize your app for maximum speed