useHref
The href of a target, resolved against the current location.
The href of a target, resolved against the current location. Reactive: relative targets update.
Import#
ts
import { useHref } from "@shadow-js/router";
Signature#
ts
function useHref(to: HrefOf, options: NavigateToOptions = {}): Accessor<string>
Parameters#
| Name | Description |
|---|---|
to |
Target. |
options |
Params, search and hash. |
Returns#
An accessor of the href.
Examples#
ts
import { useHref } from "@shadow-js/router";
const href = useHref("/posts/:id", { params: { id: "7" } });
href(); // "/posts/7"