import { useSyncExternalStore } from "react"; import { getPath, subscribe } from "./history"; import { matchRoute, type RouteDefinition } from "./routes"; export function useRoute(): { path: string; route: RouteDefinition } { const path = useSyncExternalStore(subscribe, getPath, () => "/"); return { path, route: matchRoute(path) }; }