T
TanStack7mo ago
metropolitan-bronze

Layout only files

Hey guys, here is my test of files/folders structure for my auth part. My goal is to have: - /login (login page) - /active/{generate/check/post} - /password/{generate/check/reset} But i'm a bit annoyed because actually there is a route for /activate and /password, but both password.tsx and activate.tsx are only here to define a base layout of the related folder. I don't want to give a route to those files. How can I achieve this ?
No description
4 Replies
metropolitan-bronze
metropolitan-bronzeOP7mo ago
login.tsx is a real page, not a layout. I also feel that the 2 other files can confuse because we can think "oh its the activate page", where it is only a layout Would be awesome if I can have special suffix or something to define layout only files
optimistic-gold
optimistic-gold7mo ago
not clear to me what you want to do here you need to distinguish e.g. check from activate vs. check from password
robust-apricot
robust-apricot7mo ago
I think some quick pointers here to help: - if you use _ in front of a file you can then nest items inside a directory with same name and they will use the layout (i.e. _full-page.tsx and _full-page/foobar.tsx - if you use () the router will bypass the directory completely as its only used for organization - if your use - i.e. -components/ anything inside will not be apart of the routes more details here: https://tanstack.com/router/latest/docs/framework/react/routing/file-based-routing#directory-routes
File-Based Routing | TanStack Router React Docs
Most of the TanStack Router documentation is written for file-based routing and is intended to help you understand in more detail how to configure file-based routing and the technical details behind h...
robust-apricot
robust-apricot7mo ago
So FYI based on your question just prefix with _

Did you find this page helpful?