React Router API Reference
    Preparing search index...

    Function useResolvedPath

    • Resolves the pathname of the given to value against the current Location. Similar to useHref, but returns a Path instead of a string.

      Parameters

      • to: To

        The path to resolve

      • options: { relative?: RelativeRoutingType } = {}

        Options

        • Optionalrelative?: RelativeRoutingType

          Defaults to "route" so routing is relative to the route tree. Set to "path" to make relative routing operate against path segments.

      Returns Path

      The resolved Path object with pathname, search, and hash

      import { useResolvedPath } from "react-router";

      function SomeComponent() {
      // if the user is at /dashboard/profile
      let path = useResolvedPath("../accounts");
      path.pathname; // "/dashboard/accounts"
      path.search; // ""
      path.hash; // ""
      }

      @public