useHrefResolves a full URL against the current location to be used as an href to a link. If a relative path is supplied, it will resolve to a full URL.
import { useHref } from "@remix-run/react";
function SomeComponent() {
const href = useHref("some/where");
return <a href={href}>Link</a>;
}
useHref(to, options)
toOptional. The path to append to the resolved URL.
useResolvedPath docs for a note on the behavior of the future.v3_relativeSplatPath future flag for relative useHref() behavior within splat routes
optionsThe only option is { relative: "route" | "path"}, which defines the behavior when resolving relative URLs.
.. will remove one URL segment.