TanStackT
TanStack2y ago
14 replies
ordinary-sapphire

Nested Directories with pathless underscore route not resolving path strings

Heya, I'm not sure if this is intended or simply a restriction of that approach but I wanted to structure my routes with folders like so:

- _auth
  - dashboard
    - index.lazy.tsx
  - products
    - $productNumber.tsx
    - index.lazy.tsx
- __root.tsx
- logout.tsx
- no-access.tsx


However, when I try to use <Navigate to="..." or redirect({ to: "..." it will only resolve the route paths that are not below _auth being "/", "logout" and "no-access".
As soon as I structure those routes flat via _auth.products.index.lazy.tsx it gets resolved just fine.

Is this intended? Am I doing something wrong here?
I wondered if this is because I'm using index.tsx routes that also need to end with a "/" while flat route file paths end without "/" so I guess there is some kind of difference at least?

All my routes are built like this:
export const Route = createLazyFileRoute("/_auth/products/")({
  component: ProductsPage,
});

export { Route as ProductsRoute };
Was this page helpful?