React Router API Reference
    Preparing search index...

    Function unstable_useRouteDiscovery

    • 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.

      Parameters

      Returns {
          discoverRoutes: (
              paths: string[],
              options?: { signal?: AbortSignal },
          ) => Promise<unstable_DiscoveryResult>;
          loadAllRoutes: () => Promise<void>;
          state: DiscoveryState;
          version: string;
      }

      The client version, full-manifest loading state, and discovery operations.

      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"]);

      unstable_useRouteDiscovery

      framework