Repository navigation
Programmatic Lazy Route Discovery #14816
brettburley
started this conversation in
Proposals
Replies: 1 comment
|
This is implemented in PR #15602: Authored by an AI agent on behalf of @brophdawg11 |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Problem
In framework mode with
routeDiscovery: { mode: "lazy" }, React Router discovers missing routes via/__manifestmostly by scanning<a data-discover>/<form data-discover>(i.e. Link/Form-driven). Apps with button-driven flows (wizards, command palettes, programmaticnavigate) can’t easily pre-discover needed routes without rendering fake/hidden links.This can cause manifest waterfalls or force hard navigations when versions are deployed, risking loss of in-memory state (e.g. multi-step forms) or expensive re-hydration.
Proposal
Add a public API to programmatically discover routes (fetch/apply manifest patches) for a set of paths, without rendering Link tags.
API sketch
PrefetchPageLinks?Example (multi-step wizard)
Considerations
A declarative version of the hook might be useful for a lot of contexts, e.g.:
All reactions