useNavigate
A navigate function bound to the router.
A navigate function bound to the router. Resolves with the outcome; redirects, not-found and canceled navigations resolve too (they never throw).
Import#
ts
import { useNavigate } from "@shadow-js/router";
Signature#
ts
function useNavigate(): <P extends HrefOf>(
to: P,
...options: NavigateArgs<P>
) => Promise<NavigationOutcome>
Returns#
(to, options?) => Promise<NavigationOutcome>.
Examples#
ts
const go = useNavigate(); go("/posts/7", { replace: true });