devxoul/URLNavigator — a mobile project — sits at 3.3k GitHub stars in the Mobile space. ⛵️ Elegant URL Routing for Swift
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
⛵️ URLNavigator provides an elegant way to navigate through view controllers by URLs. URL patterns can be mapped by using URLNavigator.register(_:_:) function.
URLNavigator can be used for mapping URL patterns with 2 kind of types: URLNavigable and URLOpenHandler. URLNavigable is a type which defines an custom initializer and URLOpenHandler is a closure which can be executed. Both an initializer and a closure receive an URL and placeholder values.
Getting Started
1. Understanding URL Patterns
URL patterns can contain placeholders. Placeholders will be replaced with matching values from URLs. Use < and > to make placeholders. Placeholders can have types: string(default), int, float, and path.
For example, myapp://user/<int:id> matches with:
myapp://user/123
myapp://user/87
But it doesn't match with:
myapp://user/devxoul (expected int)
myapp://user/123/posts (different url structure)
/user/devxoul (missing scheme)
2. Mapping View Controllers and URL Open Handlers
URLNavigator allows to map view controllers and URL open handlers with URL patterns. Here's an example of mapping URL patterns with view controllers and a closure. Each closures has three parameters: url, values and context.
url is an URL that is passed from push() and present().
values is a dictionary that contains URL placeholder keys and values.
context is a dictionary which contains extra values passed from push(), present() or open().
let navigator = Navigator()
// register view controllers
navigator.register("myapp://user/<int:id>") { url, values, context in
guard let userID = values["id"] as? Int else { return nil }
return UserViewController(userID: userID)
}
navigator.register("myapp://post/<title>") { url, values, context in
return storyboard.instantiateViewController(withIdentifier: "PostViewController")
}
// register url open handlers
navigator.handle("myapp://alert") { url, values, context in
let title = url.queryParameters["title"]
let message = url.queryParameters["message"]
presentAlertController(title: title, message: message)
return true
}
3. Pushing, Presenting and Opening URLs
URLNavigator can push and present view controllers and execute closures with URLs.
Provide the from parameter to push() to specify the navigation controller which the new view controller will be pushed. Similarly, provide the from parameter to present() to specify the view controller which the new view controller will be presented. If the nil is passed, which is a default value, current application's top most view controller will be used to push or present view controllers.
present() takes an extra parameter: wrap. If a UINavigationController class is specified, the new view controller will be wrapped with the class. Default value is nil.
Then call initialize() at AppDelegate's application:didFinishLaunchingWithOptions:.
@UIApplicationMain
final class AppDelegate: UIResponder, UIApplicationDelegate {
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?
) -> Bool {
// Navigator
URLNavigationMap.initialize(navigator: navigator)
// Do something else...
}
}
Implementing AppDelegate Launch Option URL
It's available to open your app with URLs if custom schemes are registered. In order to navigate to view controllers with URLs, you'll have to implement application:didFinishLaunchingWithOptions: method.
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?
) -> Bool {
// ...
if let url = launchOptions?[.url] as? URL {
if let opened = navigator.open(url)
if !opened {
navigator.present(url)
}
}
return true
}
Implementing AppDelegate Open URL Method
You'll might want to implement custom URL open handler. Here's an example of using URLNavigator with other URL open handlers.
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
// If you're using Facebook SDK
let fb = FBSDKApplicationDelegate.sharedInstance()
if fb.application(application, open: url, sourceApplication: sourceApplication, annotation: annotation) {
return true
}
// URLNavigator Handler
if navigator.open(url) {
return true
}
// URLNavigator View Controller
if navigator.present(url, wrap: UINavigationController.self) != nil {
return true
}
return false
}
Passing Extra Values when Pushing, Presenting and Opening
You can define custom URL Value Converters for URL placeholders.
For example, the placeholder <region> is only allowed for the strings ["us-west-1", "ap-northeast-2", "eu-west-3"]. If it doesn't contain any of these, the URL pattern should not match.
Add a custom value converter to the [String: URLValueConverter] dictionary on your instance of Navigator.
navigator.matcher.valueConverters["region"] = { pathComponents, index in
let allowedRegions = ["us-west-1", "ap-northeast-2", "eu-west-3"]
if allowedRegions.contains(pathComponents[index]) {
return pathComponents[index]
} else {
return nil
}
}
With the code above, for example, myapp://region/<region:_> matches with:
myapp://region/us-west-1
myapp://region/ap-northeast-2
myapp://region/eu-west-3
But it doesn't match with:
myapp://region/ca-central-1
For additional information, see the implementation of default URL Value Converters.
License
URLNavigator is under MIT license. See the LICENSE file for more info.
No homepage URL was recorded for devxoul/URLNavigator in TopGit's last sync. The README tab above frequently contains screenshots and demo links, or check the repository description on GitHub.
Is devxoul/URLNavigator open source?
Yes — devxoul/URLNavigator ships under the MIT license, which makes its source code freely readable (and, depending on license terms, forkable and reusable). Source: github.com/devxoul/URLNavigator.
What else is in the Mobile space?
devxoul/URLNavigator is tracked by TopGit under the Mobile category, alongside 4 GitHub-tagged topics. Trending and Topics pages list peer repositories of comparable stars and language.
What is devxoul/URLNavigator?
devxoul/URLNavigator (devxoul/URLNavigator) is a Swift project on GitHub. From the project's own README: ⛵️ Elegant URL Routing for Swift
What license does devxoul/URLNavigator use?
devxoul/URLNavigator is released under the MIT license. Always verify the LICENSE file directly on GitHub for the authoritative terms — license strings can be edited out of sync with a project's actual stance.
Where do I read more about devxoul/URLNavigator?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/devxoul/URLNavigator is the definitive source.
Why is devxoul/URLNavigator categorized under Mobile?
TopGit places devxoul/URLNavigator in the Mobile category based on its GitHub topics and description (tagged: "deeplink", "ios", "routing"). Categories are assigned from real repository metadata, not editorial guesswork.
Read full README in the tab above.
Curious whether URLNavigator is right for you?
Let ChatGPT, Claude, or Perplexity look into it — click below and see what AI actually says about URLNavigator.