Question regarding nested layouts
within my app i am trying to achieve a nested routing structure (for including navigation/ect for protected routes) for that i am trying to get the Directory Routes approach to apply the wrapper that /secure/index.tsx introduces around all subsequent routes (/secure/profile/index.tsx, ect)
i have probably overseen a small piece of documentation but can someone point out my mistake?
this is my routing structure
/secure/index.tsx
/secure/profile/index.tsx
could anyone give me some directions? tyvm
9 Replies
fair-rose•11mo ago
IIRC
/secure/index.tsx
will only be rendered when you're on the /secure
page
I believe what you need instead is /secure.tsx
equal-aquaOP•11mo ago
hmmm.... in my case if i want a sub route (/secure/profile for example) how would i go and come up with the folder structure? (when going for https://tanstack.com/router/latest/docs/framework/react/guide/file-based-routing#directory-routes) as my project is large in amount of routes)
ah...
fair-rose•11mo ago
equal-aquaOP•11mo ago
i see
so creating a index.tsx for a route causes it not not wrap around its children?
for example
this will work
This wont work
because than i think i understand it now
fair-rose•11mo ago
equal-aquaOP•11mo ago
aaaah
equal-aquaOP•11mo ago
equal-aquaOP•11mo ago
Thank you so much!
saved the day!
fair-rose•11mo ago
you're welcome 🙂