https://github.com/bryan-vh/voyager
Framework for navigation & routing in SwiftUI
https://github.com/bryan-vh/voyager
ios navigation routing swift swiftui
Last synced: 3 months ago
JSON representation
Framework for navigation & routing in SwiftUI
- Host: GitHub
- URL: https://github.com/bryan-vh/voyager
- Owner: bryan-vh
- License: mit
- Created: 2023-11-23T01:08:24.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-09-13T06:49:14.000Z (4 months ago)
- Last Synced: 2025-10-09T21:14:35.174Z (3 months ago)
- Topics: ios, navigation, routing, swift, swiftui
- Language: Swift
- Homepage:
- Size: 54.7 KB
- Stars: 22
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://swiftpackageindex.com/bryan-vh/Voyager)
[](https://swiftpackageindex.com/bryan-vh/Voyager)

> Lightweight framework for navigation & routing in SwiftUI
# Voyager
**Voyager** empowers developers to power their SwiftUI-based apps with routing that not only applies to navigation, but also tabs.
## Installation
In Xcode add the dependency to your project via *File > Add Packages > Search or Enter Package URL* and use the following url:
```
https://github.com/bryan-vh/Voyager.git
```
Once added, import the package in your code:
```swift
import Voyager
```
## Usage
### Route
```swift
enum ExampleRoute: Route {
case route1
case route2
case route3(String)
case route4(Int)
}
```
To start off, create an enum that will represent your set of routes. These can be parameterized by using Swift's enum with associated values.
### BaseVoyagerView
```swift
@StateObject var router = Router(root: .route1)
BaseVoyagerView(router: router) { route in
switch route {
case route1: Route1View()
case route2: Route2View()
// ...
}
}
```
The simplest of all Voyager views. Use when you don't need navigation or tabs. If you do need navigation or tabs, use the corresponding Voyager view below.
### NavVoyagerView
```swift
@StateObject var router = Router(root: .route1)
NavVoyagerView(router: router) { route in
switch route {
case route1: Route1View()
case route2: Route2View()
// ...
}
}
```
NavVoyagerView uses NavigationStack under the hood so you are able to use NavigationLink views as needed in child views.
### TabVoyagerView
```swift
@StateObject var router = TabRouter(tabs: [.route1, .route2], selected: .route1)
TabVoyagerView(router: router) { route in
switch route {
case route1: Route1View()
case route2: Route2View()
// ...
}
} tabItem: { route in
// Design a label for your tab item
}
```
TabVoyagerView uses a TabView with an array of NavVoyagerViews under the hood, so navigation works for each tab separately.
### Router
```swift
struct Route1View: View {
@EnvironmentObject var router: Router
// You can then use the router to push, pop, present modals, or dismiss as needed.
}
```
You can access a router in any child view of the parent Voyager view.
### DeeplinkHandler
```swift
final class ExampleDeeplinkHandler: DeeplinkHandler {
override func handleDeeplink(url: URL) -> (ExampleRoute, PresentationOption)? {
// Transform the deeplink into a route with a given presentation option.
}
}
```
By injecting a route-specific **DeeplinkHandler** into a **Router**, you will be able to
handle any deeplinks that would present some route from that router.
## License
[MIT License](LICENSE)