T
TanStack•2y ago
harsh-harlequin

Tanstack Router: Get the current location/path

Is there any way to retrieve the current location of the router? to give an example of what I'm talking about, in react-router it was possible to use the useLocation hook to get the pathname of the router, is there the same thing or an alternative with tanstack?
4 Replies
sunny-green
sunny-green•2y ago
how about:
const location = useRouterState({ select: (s) => s.location })
const location = useRouterState({ select: (s) => s.location })
harsh-harlequin
harsh-harlequinOP•2y ago
ow thx, Is it normal if the doc doesn't talk about hooks at all? 🥲 I also just saw that there was the useRouter hook with:
const r = useRouter();
r.state.location;
const r = useRouter();
r.state.location;
which is not mentioned either I believe
sunny-green
sunny-green•2y ago
we are in the process of updating the docs, stay tuned
harsh-harlequin
harsh-harlequinOP•2y ago
ow nice ok, thx my lord :MoaiNani:

Did you find this page helpful?