can i have multiple Pathless Route Group Directories at the same level, each with a layout inside?
i'm looking to have the following structure
i'm not actually sure that i need the layout in (static), but the key is that i dont want this group to be covered by (auth)'s layout. but even the (auth) layout is telling me i need unique paths for all routes.
one solution that i think should work, but i don't love, is to lift the layout out of (auth), and then exclude (static) like
(static)_
, or something roughly like this. i would much prefer to have auth stuff with layout all nested under there6 Replies
quickest-silver•8mo ago
(static)
creates a group, not a pathless route, _static
creates a pathless routecorrect-apricotOP•8mo ago
I don’t understand the difference?
quickest-silver•8mo ago
Route groups are only for organization and cannot have a
route.tsx
, pathless routes can have a route.tsx
.
there is no such thing as a _layout.tsx
(like other routers do) in tanstack router to create a layout, you either do
where layout
is just a placeholder name, it can be anything, or you use route.tsx
instead of that _layout.tsx
to colocate the layout with the files it wraps over
there is no way to explicitly make a "layout", the above is a pathless route that allows other routes to nest inside of it
you could also do
and on /some-route/some-other-route
both routes will match and some-other-route
will render inside the <Outlet />
from some-route.tsx
(if it has one)correct-apricotOP•8mo ago
Interesting thanks for the explanation. I don’t really understand the distinction, but I’ll opt for the pathless route as directory approach
I’m not seeing an obvious reason why one would want route groups if this is the behavior?
quickest-silver•8mo ago
ngl, I am the one that asked for groups because I was used to them from other routers, but now that I learned how to use the tanstack router it's clear that pathless routes have the functionality that groups have in other routers
correct-apricotOP•8mo ago
Ah
I really like the () syntax 😞