auto_route
Code-generated routing library for Flutter — the most feature-rich alternative to go_router and Flutter Navigator 2.0. auto_route generates type-safe route classes from annotations: @AutoRouterConfig(), @RoutePage() on widgets, and @injectable integration. Key features: type-safe route arguments (no string-based routing), route guards for auth, nested navigation stacks, tab navigation, deep linking, web URL synchronization, and declarative route tree definition. Works with get_it/injectable for DI.
Score Breakdown
⚙ Agent Friendliness
🔒 Security
No network exposure. Route guards enforce auth before navigation. Type-safe routes prevent route injection via string manipulation. Deep link validation is application responsibility.
⚡ Reliability
Best When
You're building a large Flutter app with complex navigation (nested stacks, tabs, guards, deep links) and want type-safe route arguments and code generation for navigation boilerplate.
Avoid When
You have a simple app (few routes, no guards), your team avoids build_runner code gen, or you're already invested in go_router's simpler API.
Use Cases
- • Build type-safe Flutter navigation for agent apps using auto_route — compile-time route argument checking prevents runtime navigation errors in complex agent UI flows
- • Implement auth guards for agent feature routes using AutoRouteGuard — redirect unauthenticated users to login before accessing agent dashboards
- • Create nested navigation stacks for agent feature modules — separate navigation stacks per tab or feature (agents, settings, history) with independent back stacks
- • Handle deep links and URL routing for Flutter web agent dashboards using auto_route's web support — browser URL reflects app state, history navigation works correctly
- • Integrate route code generation with injectable DI — auto_route + injectable + get_it provide compile-time navigation and dependency injection together
Not For
- • Simple apps with few routes — auto_route adds build_runner code generation overhead; go_router or Navigator.pushNamed is simpler for apps with 3-5 screens
- • Teams avoiding code generation — auto_route requires running build_runner after route changes; teams wanting zero code generation should use go_router
- • Non-Flutter Dart apps — auto_route is Flutter-specific; server-side Dart routing uses shelf_router or other HTTP routing libraries
Interface
Authentication
Routing library — no auth concepts. AutoRouteGuard interface enables auth-based navigation guards: check auth state and redirect unauthenticated users.
Pricing
auto_route is MIT licensed, maintained by Milad Akarie. Free for all use.
Agent Metadata
Known Gotchas
- ⚠ Code generation required after every route change — add/modify @RoutePage or @AutoRouterConfig requires `flutter pub run build_runner build`; forgetting this causes 'route not found' errors that look like runtime bugs
- ⚠ Part files must match — @RoutePage creates part files (route_name.gr.dart); the part directive in router config must match; version upgrades sometimes change generated file structure
- ⚠ AutoRouteGuard is async — guards return a NavigationDecision Future; blocking guard evaluation (waiting for auth check) delays navigation; use StreamProvider or StateNotifier for reactive auth state in guards
- ⚠ Nested routers require separate AutoRouter instances — each nested navigation area (tab, module) needs its own router; mixing routes between routers causes parent router to handle child routes incorrectly
- ⚠ Deep link configuration per platform — iOS requires Associated Domains entitlement and apple-app-site-association; Android requires intent-filter in AndroidManifest.xml; auto_route handles routing but platform setup is manual
- ⚠ back button behavior with nested navigation — Android hardware back button behavior in nested stacks requires careful AutoBackButton usage; default back handling may pop wrong stack in multi-stack navigation
Alternatives
Full Evaluation Report
Detailed scoring breakdown, competitive positioning, security analysis, and improvement recommendations for auto_route.
Scores are editorial opinions as of 2026-03-06.