useHref
react-router

useHref

useHref(to, props): string

Resolves a URL against the current location.

import { useHref } from "react-router"

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

Parameters

  • to: To
  • props: { relative: RelativeRoutingType, }
Docs and examples CC 4.0