Skip to content

Add opt-in application-controlled route discovery - #15602

Merged
brophdawg11 merged 13 commits into
mainfrom
brophdawg11/codex-route-discovery
Oct 15, 2026
Merged

brophdawg11 merged 13 commits into
mainfrom
brophdawg11/codex-route-discovery

Conversation

@brophdawg11

Copy link
Copy Markdown
Contributor

Implement RFC #15590 with unstable_useRouteDiscovery in conventional Framework Mode. Applications can discover selected destinations, load their running build's complete route manifest, and control recovery when incremental discovery encounters a different manifest version.

Enable the opt-in in react-router.config.ts:

export default {
  future: { unstable_customRouteDiscovery: true },
};
let { state, discoverRoutes, loadAllRoutes } = unstable_useRouteDiscovery({
  async onManifestMismatch(event) {
    try {
      await event.loadAllRoutes();
    } catch {
      await event.defaultBehavior();
    }
  },
});

Full-manifest loading downloads route metadata and preserves the running client version. Deployments must retain that version's assets and compatible server contracts. Load failures remain catchable without rendering a route error boundary.

Custom callbacks override the corresponding defaults, compose in reverse registration order, and can explicitly invoke built-in recovery through defaultBehavior(). If recovery leaves discovery incomplete, pending navigations and fetchers cancel without replaying submissions. Back/Forward cancellation restores a single pending traversal; overlapping native traversals during restoration remain a documented limitation.

The flag selects the new eager, navigation, and fetcher discovery paths and gates the associated router cancellation behavior. HydratedRouter conditionally calls the existing or custom hook based on the static flag, preserving the original render tree. The existing fog-of-war implementation is unchanged. Excluding the new code from flag-off bundles is deferred.

Authored by an AI agent on behalf of @brophdawg11

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Preview Build Available

Preview builds have been created for this PR. You can install react-router using:

pnpm install "remix-run/react-router#preview/pr-15602&path:packages/react-router"

And/or install other packages via:

pnpm install "remix-run/react-router#preview/pr-15602&path:packages/react-router-dev"
pnpm install "remix-run/react-router#preview/pr-15602&path:packages/react-router-express"
pnpm install "remix-run/react-router#preview/pr-15602&path:packages/react-router-node"
pnpm install "remix-run/react-router#preview/pr-15602&path:packages/react-router-serve"

These preview builds will be updated automatically as you push new commits.

@brophdawg11
brophdawg11 marked this pull request as ready for review October 15, 2026 17:59
@brophdawg11 brophdawg11 linked an issue Oct 15, 2026 that may be closed by this pull request
@brophdawg11
brophdawg11 merged commit d86f6b4 into main Oct 15, 2026
12 checks passed
@brophdawg11
brophdawg11 deleted the brophdawg11/codex-route-discovery branch October 15, 2026 18:19
@github-actions

Copy link
Copy Markdown
Contributor

The preview branch preview/pr-15602 has been deleted now that this PR is merged/closed.

@remix-run-bot remix-run-bot mentioned this pull request Oct 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

πŸ€– Hello there,

We recently published version 8.5.0 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RFC: Application-Controlled Route Discovery

1 participant