TanStackT
TanStack9mo ago
6 replies
dramatic-maroon

How to Clear Multiple Routes from Navigation History in TanStack Router

Navigation Flow:
- Start at /account/networks
- navigate({ to: "/account/networks/search" })
- navigate({ to: "/account/networks/search/join-dialog" })
- After success action, we want to return to /account/networks

The Issue:
When using replace: true to navigate back to /account/networks:
- Navigation to /account/networks works
- But then router.history.back() at /account/networks takes user to /account/networks/search
- We want it to go back to /account
- We need to clear both the search and join-dialog routes from history

navigate({ to: "/account/networks", replace: true });


Is there a way to clear multiple routes ( both the search and join-dialog routes) from the history stack in TanStack Router?Navigation Flow:
Was this page helpful?