T
TanStack3y ago
rising-crimson

Another circular dependency question

I've read through all the questions and answers about circular dependencies between router, the route tree, Routes and beforeLoad. Our app does work with the circular dependencies but they are breaking unit tests. Redirecting in beforeLoad with throw redirect only solves half the problem. Most of the time we need router.history.location.pathname, router.history.location.search, etc for the redirects. Even https://tanstack.com/router/v1/docs/guide/authenticated-routes#redirecting is using router.state.location.href. The only current solution I can think of is moving all of our redirection logic inside of our components, but this is much less ideal than handling it in beforeLoad. Is there any better solution for this?
Authenticated Routes | TanStack Router Docs
Authentication is an extremely common requirement for web applications. In this guide, we'll walk through how to use TanStack Router to build protected routes, and how to redirect users to login if they try to access them. The route.beforeLoad Option
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?