// The router's location hook, with each in-app navigation put past the page's // nav guard first. Pass it to ``. import { useBrowserLocation } from "wouter-preact/use-browser-location"; import { mayNavigate } from "./navGuard.js"; type Navigate = ReturnType[1]; export function useGuardedLocation( ...args: Parameters ): [string, Navigate] { const [path, navigate] = useBrowserLocation(...args); const guarded: Navigate = (to, opts) => { if (mayNavigate(String(to))) navigate(to, opts); }; return [path, guarded]; }