TanStackT
TanStack3mo ago
7 replies
racial-moccasin

Authenticated directory routes - unable to get it to work

We had file based routing for the longest time. Now with the ever increasing amount of new routes we'd like to refactor into some directories instead. For a basic example we used to have

_auth.tsx
_auth.dashboard.tsx


With _auth.tsx containing authentication logic which handles redirects and such.

Now turning it into directories

/_auth/
  index.tsx
  /dashboard/
    index.tsx


Moving the authentication logic to /_auth/index.tsx and navigating to the dashboard it skips the logic and goes straight to the dashboard. Is there a way on how all the child directories in /_auth/ must go through that logic before going to their components?
Was this page helpful?