Viewing docs for an older release. View latest
useResolvedPath

useResolvedPath

Resolves the pathname of the given to value against the pathname of the current location and returns a Path object.

import { useResolvedPath } from "@remix-run/react";

function SomeComponent() {
  const path = useResolvedPath("../some/where");
  path.pathname;
  path.search;
  path.hash;
  // ...
}

This is useful when building links from relative values and used internally for <NavLink>.

Additional Resources

Docs and examples licensed under MIT