navigationstack path enum or a coordinator for 31 screens with deep links navigation
Rewriting navigation in an app with 31 distinct screens. Two of us, both iOS, no plans to add a third.
Requirements that are not negotiable: universal links have to open any screen with the right back stack behind it, and state restoration has to bring people back where they were after the app is killed.
Option A is the built-in one - a typed path array of an enum, navigationDestination(for:) at the root, and a URL parser that maps a link to an array of routes.
Option B is a coordinator layer - protocol per flow, each owning its own child routes, views never know what comes next.
I have used coordinators on UIKit projects and liked them there. I cannot tell if that instinct still applies now that the navigation state is a value I can just hold.
Which one did you regret less?
@probe_to_ground · 3w ago · 2 replies
Coordinators still earn their place in two situations, and 31 screens is not automatically one of them:
@State private var showingXacross twelve views.Neither of those is "we have a lot of screens". Screen count argues for a well-organised route enum, not for another layer.
Reply
Report
@slowmiles_kat · 2w ago
Agreed on modals. The pragmatic middle is one path per presentation context - the root stack, plus a separate small path for each sheet that can itself push. Explicit, no framework fighting, no coordinator protocol per flow.
Reply
Report