T
TanStack3y ago
extended-salmon

Going back to previous route

Hey guys, I have a question. Is it possible with the tanstack router to go back to the previous visited route? something like const nav = useNavigate() nav({ to: -1 })
3 Replies
generous-apricot
generous-apricot3y ago
@Ishida You can try something like
let router = useRouter();
router.history.back();
let router = useRouter();
router.history.back();
rival-black
rival-black3y ago
Yes, this the recommended way.
correct-apricot
correct-apricot3y ago
Is there a way to get the info of this previous route so that we can pass it to the to prop of a <Link> component, or to be able to use it in different places? I'm currently using search params but they are strings so things are getting complicated there

Did you find this page helpful?