Skip to main content

useResolvedPath

declare function useResolvedPath(to: To): Path;

interface Path {
pathname: string;
search: string;
hash: string;
}

This hook resolves the pathname of the location in the given to value against the pathname of the represented by the nearest <Route> layout or global pathname if no layout is found.

This is useful when building links from relative values.

This is a wrapper around useResolvePath hook that simply immediately calls it during rendering and not on a user interaction like click or touch.

info

useResolvedPath hook is used internally by <RouterLink> and <RouterNavLink> to build relative and absolute link hrefs.