Apply _pathless.tsx layout to index.tsx?
Hi there 👋 I am wanting my index route to situate without a nested layout. I use a
_main.tsx
layout to wrap a number of pages and these pages are split into two sub layouts which process auth status, _protected.tsx
and _unprotected.tsx
. I want the index of my route tree (/
) to situate within the _protected.tsx
layout. How can I accomplish this? Prefixing index.tsx
with _protected.index.tsx
does not seem to work. Any help is appreciated!
3 Replies
environmental-rose•10mo ago
that won't work
you cannot opt out of a grandparent layout
one option is to invert the order of layouts and repeat _main
_protected/
_main/
index.tsx
_unprotected/
_main/
...
another option is to use virtual file routes
eager-peachOP•10mo ago
Ideally I'd have my index route situated within both
_main
nad _protected
. Is this not really doable? This can be done in the nextjs app router since layouts are applied to both route groups and routes.environmental-rose•10mo ago
maybe I misunderstood. should both _main and _protected be applied for index.tsx?