T
TanStack2y ago
correct-apricot

How to get the full path?

Is there any way of getting the whole path without me always having to use the javascript location.pathname?
3 Replies
ambitious-aqua
ambitious-aqua2y ago
const location = useRouterState({ select: s => s.location })
// this should have pathname in it

// or even
const pathname = useRouterState({ select: s => s.location.pathname })
const location = useRouterState({ select: s => s.location })
// this should have pathname in it

// or even
const pathname = useRouterState({ select: s => s.location.pathname })
ambitious-aqua
ambitious-aqua2y ago
useRouterState hook | TanStack Router Docs
The useRouterState method is a hook that returns the current internal state of the router. This hook is useful for accessing the current state of the router in a component. useRouterState options
correct-apricot
correct-apricotOP2y ago
Thanks 👍

Did you find this page helpful?