React Router API Reference
    Preparing search index...

    Function unstable_useRoute

    • Returns the current route's handle, loaderData, and actionData, or those of a matched route identified by routeId.

      Omit routeId to read the current route. Pass a route ID to infer the fields from registered route module types. Without an ID, the fields are typed as unknown.

      Type Parameters

      • Args extends UseRouteArgs

      Parameters

      • ...args: Args

        An optional route ID. Omit it to read the current route.

      Returns UseRouteResult<Args>

      An object with the route's handle, loaderData, and actionData, or undefined if the specified route is not matched. Individual fields can be undefined when the handle or data is unavailable.

      import { unstable_useRoute as useRoute } from "react-router";

      let currentRoute = useRoute();
      let rootRoute = useRoute("root");

      // A registered non-root route may not currently be matched:
      let dashboard = useRoute("routes/dashboard");
      if (dashboard) {
      console.log(dashboard.handle, dashboard.loaderData);
      }

      unstable_useRoute

      framework

      data