top of page

Routing library for SwiftUI Navigation

Writer's picture: Eric PalmaEric Palma

Updated: Dec 31, 2024

At last, I have achieved a version of the Router pattern that I am happy with and addresses the problems I intended to solve when I started.


  • Remove navigation specific APIs from SwiftUI views.

  • Prevent views from knowing about other views and how to build them.

  • Shield views from knowing how other views are navigated to.


It is the result of all the exploratory work and iterations I made in previous posts:


Table of Contents

  1. Removing Navigation APIs from SwiftUI Views

    • Introducing the RoutingView as a wrapper.

    • Decoupling views from SwiftUI navigation APIs.

    • Injecting a Router instance into the view hierarchy.

  2. Moving Navigation Logic to the Router

    • How the Router manages navigation.

    • Simplifying view navigation with routeTo(_).

    • Programmatically manipulating the navigation stack.

  3. Achieving Modularity with the Routable Protocol

    • Defining navigation for modularized codebases.

    • Eliminating circular dependencies in the library.

    • Example implementation of the Routable protocol.

  4. Next Steps and Community Contributions

    • Future plans for the library.

    • How to contribute or provide feedback.


You can download the entire code for this library below:

Want to read more?

Subscribe to curiousalgorithm.com to keep reading this exclusive post.

Site
Join the growing community of iOS engineers who are taking their skills to the next level.

© 2025 Curious Algorithm. All rights reserved.

bottom of page