T
TanStack•14mo ago
fair-rose

Router layouts inside subdirectory and prefixing

Gut check since I'm mostly brand new to Router and start, when creating a layout for a sub-route, it shows here that you could define it like this to create a Posts layout, is there any way to keep that layout file inside the subdirectory without having to prefix all the other pages inside it such as index and $postId?
No description
21 Replies
harsh-harlequin
harsh-harlequin•14mo ago
what do you mean by " without having to prefix all the other pages inside it such as index and $postId?" ?
fair-rose
fair-roseOP•14mo ago
like, in my start project this is how im doing a layout for all /logs routes
fair-rose
fair-roseOP•14mo ago
No description
fair-rose
fair-roseOP•14mo ago
that may be completely wrong already, though lol
harsh-harlequin
harsh-harlequin•14mo ago
hmmm
fair-rose
fair-roseOP•14mo ago
where _logs.tsx is the layout I'd prefer to just have like: _layout.tsx, index.tsx, $logId.tsx, and legacy.$logId.tsx
harsh-harlequin
harsh-harlequin•14mo ago
so you can do a lot of variations here
logs/
_logs.tsx
_logs/
index.tsx
$logId.tsx
logs/
_logs.tsx
_logs/
index.tsx
$logId.tsx
or just this, no separate layout:
logs.tsx <== put the layout in here!
logs/
index.tsx
$logId.tsx
logs.tsx <== put the layout in here!
logs/
index.tsx
$logId.tsx
or this
logs/
route.tsx <== put the layout in here!
index.tsx
$logId.tsx
logs/
route.tsx <== put the layout in here!
index.tsx
$logId.tsx
fair-rose
fair-roseOP•14mo ago
ahhh so route.tsx sort of functions like layout.tsx in next?
harsh-harlequin
harsh-harlequin•14mo ago
it can act as such it is "just" the route definition of the "logs" route and as such it can also have a component and that component can render more than just an <Outlet> and that is then what can be called a "layout"
fair-rose
fair-roseOP•14mo ago
I see many options here now to pick one 🤣 ty
harsh-harlequin
harsh-harlequin•14mo ago
you can also rename "route.tsx" to something else its configurable
fair-rose
fair-roseOP•14mo ago
😳
harsh-harlequin
harsh-harlequin•14mo ago
just to open up some more things
fair-rose
fair-roseOP•14mo ago
where @?
harsh-harlequin
harsh-harlequin•14mo ago
TanStack | High Quality Open-Source Software for Web Developers
Headless, type-safe, powerful utilities for complex workflows like Data Management, Data Visualization, Charts, Tables, and UI Components.
From An unknown user
From An unknown user
harsh-harlequin
harsh-harlequin•14mo ago
No description
fair-rose
fair-roseOP•14mo ago
cool, would go in app.config.ts?
harsh-harlequin
harsh-harlequin•14mo ago
can go there, yes
fair-rose
fair-roseOP•14mo ago
or in router.tsx
harsh-harlequin
harsh-harlequin•14mo ago
no, in app.config.ts (or in tsr.config.json)
fair-rose
fair-roseOP•14mo ago
thats awesome thanks man

Did you find this page helpful?