useRouteDiscovery
unstable_useRouteDiscovery
Framework
Warning
This API is experimental and subject to breaking changes in minor/patch releases. Please use with caution and pay very close attention to release notes for relevant changes.
Summary
Control lazy route discovery in Framework Mode with future.unstable_customRouteDiscovery
enabled. This allows you to imperatively discover routes as well as add custom behavior
when a manifest version mismatch is detected. Calling loadAllRoutes will load the entire
route manifest for the current (potentially stale) client version - this requires that prior
client artifacts are still available on your CDN and you have not made breaking changes to
the API contracts of your loaders and actions.
See the Route Discovery guide for more information and examples.
let { state, discoverRoutes, loadAllRoutes } = unstable_useRouteDiscovery({
onManifestMismatch: async (event) => {
// Eagerly load the complete route tree for this client without requiring a hard reload
await event.loadAllRoutes();
},
});
// Eagerly discover specific routes
discoverRoutes(["/a", "/b"]);Signature
function useRouteDiscovery(options: RouteDiscoveryOptions = {})Params
options
An awaited manifest-mismatch handler.
Returns
The client version, full-manifest loading state, and discovery operations.