T
TanStack13mo ago
genetic-orange

Can we get a layout file type for file based routing?

It's sort of annoying sometimes where the _layout files and directories aren't sorted cleanly. And overall I find it a little confusing. Has a *.layout.tsx file type ever been considered? So we can do something like this?
.
└── routes/
├── _auth/
│ ├── index.tsx
│ ├── layout.tsx # or custom-name.layout.tsx
│ ├── welcome.tsx
│ └── dashboard/
│ ├── index.tsx
│ ├── route-a.tsx
│ └── route-b.tsx
├── login.tsx
└── logout.tsx
.
└── routes/
├── _auth/
│ ├── index.tsx
│ ├── layout.tsx # or custom-name.layout.tsx
│ ├── welcome.tsx
│ └── dashboard/
│ ├── index.tsx
│ ├── route-a.tsx
│ └── route-b.tsx
├── login.tsx
└── logout.tsx
No description
16 Replies
fascinating-indigo
fascinating-indigo13mo ago
what does "not sorted cleanly" mean for you exactly?
genetic-orange
genetic-orangeOP13mo ago
i.e. the ordering
No description
genetic-orange
genetic-orangeOP13mo ago
I also think its just easier to grok having the layout file inside the directory, everything relevant to the pathless route is in the same place than a lonely file route as a sibling of the pathless directory @Manuel Schiller
fascinating-indigo
fascinating-indigo13mo ago
you can have the layout file inside the directory just name it route.tsx (for now that name is hard coded but will be made configurable )
genetic-orange
genetic-orangeOP13mo ago
amazing, thank you
fascinating-indigo
fascinating-indigo13mo ago
btw this is now configurable, so you can use another name than "route" if you want
absent-sapphire
absent-sapphire12mo ago
hey bro, please explain. So if i have:
routes/
login/
index.tsx
route.tsx # this can be layout.tsx now or smth?
routes/
login/
index.tsx
route.tsx # this can be layout.tsx now or smth?
Im new, and docs are fuzzy with layouts. Thanks a bunch
fascinating-indigo
fascinating-indigo12mo ago
yes you could use "layout" instead of "route" if you want to
fascinating-indigo
fascinating-indigo12mo 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
fascinating-indigo
fascinating-indigo12mo ago
No description
fascinating-indigo
fascinating-indigo12mo ago
however, I would only recommend doing this if necessary because now you are diverging from the "standard" conventions and it will be harder for people to understand
absent-sapphire
absent-sapphire12mo ago
Is there some sort of config parameter I’m supposed to specify? For some reason I can get route to work but not layout.
fascinating-indigo
fascinating-indigo12mo ago
yes, the config parameter that I screenshotted above routeToken
absent-sapphire
absent-sapphire12mo ago
routeFilePrefix Ahh I see thx
fascinating-indigo
fascinating-indigo12mo ago
no routeToken
absent-sapphire
absent-sapphire12mo ago
Gotchu. Appreciate it

Did you find this page helpful?