{"id":26166415,"url":"https://github.com/jamessedlacek/routing","last_synced_at":"2025-05-16T01:07:13.993Z","repository":{"id":212741385,"uuid":"732202613","full_name":"JamesSedlacek/Routing","owner":"JamesSedlacek","description":"SwiftUI library for abstracting navigation logic from views","archived":false,"fork":false,"pushed_at":"2025-05-07T23:44:16.000Z","size":2432,"stargazers_count":431,"open_issues_count":0,"forks_count":24,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-05-08T00:29:05.547Z","etag":null,"topics":["abstraction","navigation","navigationdestination","navigationlink","navigationstack","routing","swiftui"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JamesSedlacek.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-12-15T22:59:52.000Z","updated_at":"2025-05-07T23:57:06.000Z","dependencies_parsed_at":"2024-02-11T03:19:42.941Z","dependency_job_id":"4921f77f-5709-42cd-94b6-235b783ffa69","html_url":"https://github.com/JamesSedlacek/Routing","commit_stats":{"total_commits":63,"total_committers":5,"mean_commits":12.6,"dds":0.4444444444444444,"last_synced_commit":"b996580a66fc66f9ea01222b18a281f157001161"},"previous_names":["jamessedlacek/routing"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JamesSedlacek%2FRouting","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JamesSedlacek%2FRouting/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JamesSedlacek%2FRouting/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JamesSedlacek%2FRouting/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JamesSedlacek","download_url":"https://codeload.github.com/JamesSedlacek/Routing/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254448579,"owners_count":22072764,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["abstraction","navigation","navigationdestination","navigationlink","navigationstack","routing","swiftui"],"created_at":"2025-03-11T16:52:43.382Z","updated_at":"2025-05-16T01:07:08.983Z","avatar_url":"https://github.com/JamesSedlacek.png","language":"Swift","readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src = \"https://github.com/JamesSedlacek/Routing/blob/main/Assets/RoutingBannerArt.png\"\u003e\n\u003c/p\u003e\n\n[![Swift Package Manager](https://img.shields.io/badge/Swift%20Package%20Manager-compatible-brightgreen.svg)](https://github.com/apple/swift-package-manager)\n[![GitHub stars](https://img.shields.io/github/stars/JamesSedlacek/Routing.svg)](https://github.com/JamesSedlacek/Routing/stargazers)\n[![GitHub forks](https://img.shields.io/github/forks/JamesSedlacek/Routing.svg?color=blue)](https://github.com/JamesSedlacek/Routing/network)\n[![GitHub contributors](https://img.shields.io/github/contributors/JamesSedlacek/Routing.svg?color=blue)](https://github.com/JamesSedlacek/Routing/network)\n\u003ca href=\"https://github.com/JamesSedlacek/Routing/pulls\"\u003e\u003cimg src=\"https://img.shields.io/github/issues-pr/JamesSedlacek/Routing\" alt=\"Pull Requests Badge\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/JamesSedlacek/Routing/issues\"\u003e\u003cimg src=\"https://img.shields.io/github/issues/JamesSedlacek/Routing\" alt=\"Issues Badge\"/\u003e\u003c/a\u003e\n\n## Description\n\n`Routing` is a **lightweight** SwiftUI navigation library.\n- Leverages 1st-party APIs `NavigationStack` \u0026 `NavigationDestination`.\n- Never be confused about `NavigationLink` or `NavigationPath` again! (You don't need them)\n- Type-Safe Navigation (better performance than type-erasing).\n- Centralized Navigation Logic.\n- Dynamic Navigation Stack Management.\n- Unit Tested protocol implementations.\n- Zero 3rd party dependencies.\n- [Documentation](https://jamessedlacek.github.io/documentation/routing)\n\nNote - This library is for **NavigationStack** only. \u003cbr\u003e\nIf you need to abstract sheets, alerts, etc. then use my other library [`Presenting`](https://github.com/JamesSedlacek/Presenting)\n\n\u003cbr\u003e\n\n## Table of Contents\n1. [Requirements](#requirements)\n2. [Installation](#installation)\n3. [Getting Started](#getting-started)\n4. [Passing Data Example](#passing-data-example)\n5. [Under the hood](#under-the-hood)\n6. [Author](#author)\n\n\u003cbr\u003e\n\n## Requirements\n\n| Platform | Minimum Version |\n|----------|-----------------|\n| iOS      | 16.0            |\n| macOS    | 13.0            |\n| tvOS     | 16.0            |\n| watchOS  | 9.0             |\n\n\u003cbr\u003e\n\n## Installation\n\nYou can install `Routing` using the Swift Package Manager.\n\n1. In Xcode, select `File` \u003e `Add Package Dependencies`.\n\u003cp align=\"left\"\u003e\n  \u003cimg src = \"https://github.com/JamesSedlacek/Routing/blob/main/Assets/Installation1.png\" width=\"350\"\u003e\n\u003c/p\u003e\n\u003cbr\u003e\n\n2. Copy \u0026 paste the following into the `Search or Enter Package URL` search bar.\n```\nhttps://github.com/JamesSedlacek/Routing.git\n```\n\n\u003cp align=\"left\"\u003e\n  \u003cimg src = \"https://github.com/JamesSedlacek/Routing/blob/main/Assets/Installation2.png\" width=\"350\"\u003e\n\u003c/p\u003e\n\u003cbr\u003e\n\n3. Xcode will fetch the repository \u0026 the `Routing` library will be added to your project.\n\n\u003cbr\u003e\n\n## Getting Started\n\n1. Create a `Route` enum that conforms to the `Routable` protocol.\n\n``` swift\nimport Routing\nimport SwiftUI\n\nenum ExampleRoute: Routable {\n    case detail\n    case settings\n    \n    var body: some View {\n        switch self {\n        case .detail:\n            DetailView()\n        case .settings:\n            SettingsView()\n        }\n    }\n}\n```\n\n2. Create a `Router` object and wrap your `RootView` with a `RoutingView`.\n\n``` swift\nimport SwiftUI\nimport Routing\n\nstruct ContentView: View {\n    @StateObject private var router: Router\u003cExampleRoute\u003e = .init()\n\n    var body: some View {\n        RoutingView(stack: $router.stack) {\n            Button(\"Go to Settings\") {\n                router.navigate(to: .settings)\n            }\n        }\n    }\n}\n```\n\n3. Handle navigation using the `Router` functions\n\n```swift\n/// Navigate back in the stack by a specified count.\nfunc navigateBack(_ count: Int)\n\n/// Navigate back to a specific destination in the stack.\nfunc navigateBack(to destination: Destination)\n\n/// Navigate to the root of the stack by emptying it.\nfunc navigateToRoot()\n\n/// Navigate to a specific destination by appending it to the stack.\nfunc navigate(to destination: Destination)\n\n/// Navigate to multiple destinations by appending them to the stack.\nfunc navigate(to destinations: [Destination])\n\n/// Replace the current stack with new destinations.\nfunc replace(with destinations: [Destination])\n```\n\n\u003cbr\u003e\n\n## Passing Data Example\n\n```swift\nimport Routing\nimport SwiftUI\n\nenum ContentRoute: Routable {\n    case detail(Color)\n    case settings\n\n    var body: some View {\n        switch self {\n        case .detail(let color):\n            ColorDetail(color: color)\n        case .settings:\n            SettingsView()\n        }\n    }\n}\n\nstruct ContentView: View {\n    @StateObject private var router: Router\u003cContentRoute\u003e = .init()\n    private let colors: [Color] = [.red, .green, .blue]\n\n    var body: some View {\n        RoutingView(stack: $router.stack) {\n            List(colors, id: \\.self) { color in\n                color\n                    .onTapGesture {\n                        router.navigate(to: .detail(color))\n                    }\n            }\n        }\n    }\n}\n\nstruct ColorDetail: View {\n    private let color: Color\n\n    init(color: Color) {\n        self.color = color\n    }\n\n    var body: some View {\n        color.frame(maxWidth: .infinity, maxHeight: .infinity)\n    }\n}\n```\n\n\u003cbr\u003e\n\n## Under the hood\n\nThe `RoutingView` essentially is just wrapping your view with a `NavigationStack` \u0026 `navigationDestination`.\n``` swift\nNavigationStack(path: $routes) {\n    root()\n        .navigationDestination(for: Routes.self) { view in\n            view\n        }\n}\n```\n\n## Author\n\nJames Sedlacek, find me on [X/Twitter](https://twitter.com/jsedlacekjr) or [LinkedIn](https://www.linkedin.com/in/jamessedlacekjr/)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamessedlacek%2Frouting","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjamessedlacek%2Frouting","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamessedlacek%2Frouting/lists"}