T
TanStack•16mo ago
rival-black

Possible to escape parent nesting inside a folder?

I have this example folder structure:
routes
- library
route.tsx
playlists.tsx
albums.tsx
$playlistId.tsx
routes
- library
route.tsx
playlists.tsx
albums.tsx
$playlistId.tsx
I want to be able to load /library/$playlistId and not have it render inside of library/route.tsx Outlet. Breaking this outside of the group with a "flat" file structure I can achieve this:
routes
- library
route.tsx
playlists.tsx
albums.tsx
- library_.$playlistId.tsx
routes
- library
route.tsx
playlists.tsx
albums.tsx
- library_.$playlistId.tsx
But I haven't found a way to do this when the file inside the folder starts with a $param and it should break outside of its parent. Any advice?
4 Replies
extended-salmon
extended-salmon•16mo ago
the param being there doesn't matter right? it's the same for albums.tsx
rival-black
rival-blackOP•16mo ago
True! So basically being able to escape nesting for a direct child route in a folder
extended-salmon
extended-salmon•16mo ago
I don't think we have a syntax for this specific case 🤔 @Sean Cassiere any idea?
ambitious-aqua
ambitious-aqua•16mo ago
If you are trying to break out of the parent route logic, then you'd have to do it the way mentioned in your OP. Flat would be:
src/routes
library.tsx
library.playlists.tsx
library.albums.tsx
library_.$playlistId.tsx
src/routes
library.tsx
library.playlists.tsx
library.albums.tsx
library_.$playlistId.tsx
In folders, it'd be pretty similar to what you did above.
src/routes
library.tsx
library/
playlists.tsx
albums.tsx
library_/
$playlistId.tsx
src/routes
library.tsx
library/
playlists.tsx
albums.tsx
library_/
$playlistId.tsx
Edit: In the folder layout, you could substitute library.tsx for library/route.tsx to match what you were doing. I just tend not to use the .route token, since I prefer having the files correspond to the actual URL segments 😅.

Did you find this page helpful?