Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Arouter | 14,264 | 208 | 2 | 15 days ago | 12 | August 29, 2018 | 119 | apache-2.0 | Java | |
💪 A framework for assisting in the renovation of Android componentization (帮助 Android App 进行组件化改造的路由框架) | ||||||||||
React Native Router Flux | 9,013 | 3,478 | 99 | 3 months ago | 273 | March 26, 2021 | 338 | mit | JavaScript | |
The first declarative React Native router | ||||||||||
Wouter | 5,508 | 7 | 61 | 2 days ago | 49 | May 17, 2023 | 22 | JavaScript | ||
🥢 A minimalist-friendly ~1.5KB routing for React and Preact. Nothing else but HOOKS. | ||||||||||
Hookrouter | 1,506 | 51 | 22 | 2 years ago | 18 | December 01, 2020 | 50 | JavaScript | ||
The flexible, and fast router for react that is entirely based on hooks | ||||||||||
Voyager | 1,420 | 9 | 2 days ago | 23 | September 04, 2023 | 68 | mit | Kotlin | ||
🛸 A pragmatic navigation library for Jetpack Compose | ||||||||||
Auto_route_library | 1,368 | 1 | 17 | 6 days ago | 113 | August 26, 2023 | 56 | mit | Dart | |
Flutter route generator | ||||||||||
Redux Little Router | 1,079 | 55 | 16 | 5 years ago | 60 | October 01, 2018 | 49 | mit | JavaScript | |
A tiny router for Redux that lets the URL do the talking. | ||||||||||
Hll Wp Therouter Android | 904 | 7 days ago | 4 | September 23, 2022 | 5 | apache-2.0 | Kotlin | |||
A framework for assisting in the renovation of Android componentization | ||||||||||
Compass | 819 | 12 | 5 years ago | 17 | October 22, 2018 | 6 | other | Swift | ||
:earth_africa: Compass helps you setup a central navigation system for your application | ||||||||||
Found | 789 | 73 | 33 | 2 months ago | 82 | January 10, 2022 | 92 | mit | TypeScript | |
Extensible route-based routing for React applications |
Deprecated and no longer supported. Use at your own risks.
This has been used extensively and after weighing up pros and cons, we now favour the use of native Flow Controllers or Coordinators as explained here.
The native route (pun intended) should always be favoured and we believe less dependencies is something we should always strive for.
Reason - Get Started - Installation
Because classic App Navigation introduces tight coupling between ViewControllers. Complex Apps navigation can look like a gigantic spider web.
Besides the fact that Navigation responsibility is split among ViewControllers, modifying a ViewController can cascade recompiles and produce slow compile times.
By using a Navigation enum
to navigate we decouple ViewControllers between them. Aka they don't know each other anymore. So modifying VCA
won't trigger VCB
to recompile anymore \o/
// navigationController?.pushViewController(AboutViewController(), animated: true)
navigate(.about)
Navigation code is now encapsulated in a AppNavigation
object.
enum MyNavigation: Navigation {
case about
case profile(Person)
}
Swift enum can take params! Awesome for us because that's how we will pass data between ViewControllers :)
struct MyAppNavigation: AppNavigation {
func viewcontrollerForNavigation(navigation: Navigation) -> UIViewController {
if let navigation = navigation as? MyNavigation {
switch navigation {
case .about:
return AboutViewController()
case .profile(let p):
return ProfileViewController(person: p)
}
}
return UIViewController()
}
func navigate(_ navigation: Navigation, from: UIViewController, to: UIViewController) {
from.navigationController?.pushViewController(to, animated: true)
}
}
A cool thing is that the swift compiler will produce an error if a navigation case is not handled ! Which would'nt be the case with string URLs by the way ;)
In AppDelegate.swift
, before everything :
Router.default.setupAppNavigation(appNavigation: MyAppNavigation())
You can now call nagivations from you view controllers :
navigate(MyNavigation.about)
Bridge Navigation
with your own enum type, here MyNavigation
so that we don't have to type our own.
extension UIViewController {
func navigate(_ navigation: MyNavigation) {
navigate(navigation as Navigation)
}
}
You can now write :
navigate(.about)
Another cool thing about decoupling navigation is that you can now extract traking code from view Controllers as well. You can be notified by the router whenever a navigation happened.
Router.default.didNavigate { navigation in
// Plug Analytics for instance
GoogleAnalitcs.trackPage(navigation)
}
There is a nasty bug in Swift 3 compiler where the compiler rebuilds files even though they haven't changed. This is documented here : https://forums.developer.apple.com/thread/62737?tstart=0
Due to this bug, the compilation can go like this :
Change ViewController1
-> Build
-> Compiles ViewController1
, referenced in MyAppNavigation
so
MyAppNavigation
gets recompiled. MyAppNavigation
is referenced in AppDelegate
which gets recompiled which references ...
App
-> ViewController2
-> ViewController3
-> ViewControllerX
you get the point.
Before you know it the entire App gets rebuilt :/
A good this is that most of the app coupling usually comes from navigation. which Router decouples.
We can stop this nonsense until this gets fixed in a future release of Xcode. Router can help us manage this issue by injecting our AppNavigation implementation at runtime.
In your AppDelegate.swift
// Inject your AppNavigation at runtime to avoid recompilation of AppDelegate :)
Router.default.setupAppNavigation(appNavigation: appNavigationFromString("YourAppName.MyAppNavigation"))
And make sure your AppNavigation
implementation is now a class
that is RuntimeInjectable
class MyAppNavigation: RuntimeInjectable, AppNavigation {
github "freshOS/Router"
Simply Copy and Paste Router.swift
files in your Xcode Project :)
Grab this repository and build the Framework target on the example project. Then Link against this framework.
Like the project? Offer coffee or support us with a monthly donation and help us continue our activities :)
Become a sponsor and get your logo on our README on Github with a link to your site :)