useHref
On this page

useHref

Summary

Reference Documentation ↗

Resolves a URL against the current location.

import { useHref } from "react-router";

function SomeComponent() {
  let href = useHref("some/where");
  // "/resolved/some/where"
}

Signature

useHref(to: To, { relative }: {
    relative?: RelativeRoutingType;
} = {}): string

Params

to

The path to resolve

options.relative

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

Docs and examples CC 4.0
Edit