
AppRouter
github.com/dimillian/approuter- Category
- Developer Tools
- Rank
- No. 1502Tools index
Previous survey · No. 1511 ·
- Pricing
- Open Source
- Type
- TOOL
- Builder
- dimillian
- GitHub
- 475 stars
- Latest release
- 1.0.2
- Date
About
Dimillian's simple router for SwiftUI apps — declarative navigation patterns without the navigation-stack gotchas.
What it does
AppRouter keeps SwiftUI navigation state in observable, main-thread-bound objects. Choose one stack or separate stacks per tab. Your own destination and sheet types define screens, while the library handles pushes, pops, root resets, sheet state, and URL-driven path replacement.
Why it's ranked here
This is a focused library with a small public model and useful coverage beyond basic pushes. Independent tab histories, sheet state, contextual deep links, examples, unit tests, and continuous build checks make it credible. Its narrow platform floor and app-defined URL parsing keep it from being universal.
What's good
Navigation state stays typed through generic destination, sheet, and tab protocols. Tab switching preserves each tab's path. URL routing can build a whole stack, pass query values, and distinguish identical path segments by their surrounding path. Main-actor isolation matches UI state ownership.
Tradeoffs
Deep-link parsing is work every destination type must supply. Unknown URL components are skipped, and routing succeeds when at least one component resolves, which may accept partial paths. A URL navigation replaces the current path rather than appending. Generated deep-link text uses destination descriptions, so applications must keep generation and parsing conventions aligned.
How to use it well
Use it in modern SwiftUI applications that want typed navigation state shared through the environment, especially tabbed apps with separate histories. Define route enums, centralize URL parsing, and test every supported path. Keep view construction and incoming URL-scheme configuration in the application because AppRouter does not own either.
Technical notes+
Package.swift defines a Swift 5.9 library product with no package dependencies and Apple platform minimums. Sources/AppRouter/Router.swift stores per-tab destination arrays, while Sources/AppRouter/SimpleRouter.swift stores one array; both types are marked @Observable and @MainActor. Sources/AppRouter/URLNavigationHelper.swift combines the URL host and path, flattens query items into a dictionary, asks DestinationType.from(path:fullPath:parameters:) to resolve each component, skips unresolved components, and replaces the active path when at least one destination resolves. Sources/AppRouter/Extensions.swift builds URLs from String(describing:) values. Tests/AppRouterTests/AppRouterTests.swift and Tests/AppRouterTests/SimpleRouterTests.swift exercise navigation, sheets, path replacement, invalid URLs, parameters, independent tab state, and contextual routes.
Observed
- License
- MIT License
- Primary language
- Swift
- Packaging
- Swift Package Manager library product named AppRouter
- Interface
- Swift library for SwiftUI applications
- Platform support
- iOS 17+, macOS 14+, tvOS 17+, and watchOS 10+
- Dependencies
- No external package dependencies; source imports SwiftUI and Foundation
- Tests
- Two XCTest source files cover the tab router and single-stack router
Read from README.md, Package.swift, Sources/AppRouter/Router.swift, Sources/AppRouter/Protocols.swift, Sources/AppRouter/Extensions.swift, Sources/AppRouter/SimpleRouter.swift, Sources/AppRouter/URLNavigationHelper.swift, Examples/AppRouter.swift, Examples/URLRoutingExample.swift, Tests/AppRouterTests/AppRouterTests.swift, Tests/AppRouterTests/SimpleRouterTests.swift, LICENSE, CLAUDE.md, .vscode/settings.json, .github/workflows/approuter.yml.
What it can do
Route between SwiftUI views declaratively
SwiftUI view definitions and route configurations → Navigated SwiftUI interface
Handle programmatic navigation without NavigationStack issues
Navigation commands and destination views → Clean view transitions
Define navigation patterns through code
Route definitions and navigation rules → Configured navigation system
Manage view state during navigation
View state data and navigation events → Preserved or updated view state
Create custom navigation flows
Custom route definitions and flow logic → Implemented navigation patterns
Tags
Tech Stack
Comments (0)
No comments yet
Editorially curated, with community endorsements as a secondary signal. Corrections welcome.