T
TanStack5mo ago
rival-black

Help regarding directory based routing

I have this weird case where I need two layouts for protected and public routes public -> /login|forget-password (those share a layout) protected -> /dashboard|users (those share a layout) As you can see, both of those don't have a prefix I can depend on. I noticed that pathlessLayout might fix this but I can create only one of it ? I am a bit confused on how to achieve this
3 Replies
rival-black
rival-blackOP5mo ago
from docs, this is the example that matches what Im talking about
routes/
├── index.tsx
├── (app)/
│ ├── dashboard.tsx
│ ├── settings.tsx
│ ├── users.tsx
├── (auth)/
│ ├── login.tsx
│ ├── register.tsx
routes/
├── index.tsx
├── (app)/
│ ├── dashboard.tsx
│ ├── settings.tsx
│ ├── users.tsx
├── (auth)/
│ ├── login.tsx
│ ├── register.tsx
but with this approach, I need to wrap every page with an AppLayout wrapper component right ? Is pathlessLayout a reserved word because I think I managed to get it fixed with _publicLayout _protectedLayout
flat-fuchsia
flat-fuchsia5mo ago
don't use route groups for that just use the _ prefixed files and directories
rival-black
rival-blackOP5mo ago
Yeah, I just thought that pathlessLayout was a reserved keyword but you can write anything you like. thanks a lot man, I ended up with those 2 _publicLayout _protectedLayout

Did you find this page helpful?