How to use parallel routes properly?
Unanswered
Havana posted this in #help-forum
HavanaOP
Hi everyone, I am trying to create a dashboard with a sidebar using parallel routes in this following structure but I keep getting 404 whenever I navigate to
Isn't it possible to use a parallel route on a parent layout and create children routes that will render on the parent layout?
localhost:3000/accountsIsn't it possible to use a parallel route on a parent layout and create children routes that will render on the parent layout?
5 Replies
@Havana Hi everyone, I am trying to create a dashboard with a sidebar using parallel routes in this following structure but I keep getting 404 whenever I navigate to `localhost:3000/accounts`
Isn't it possible to use a parallel route on a parent layout and create children routes that will render on the parent layout?
You need to have
you can also use
/@sidebar/accounts/page.tsx in order for it to workyou can also use
/@sidebar/[...slug]/page.tsx to catch all routes in the parallel side of the routing if you dont want to create duplicates for all sub pages@ᴉuɐpɹɐɐ You need to have `/@sidebar/accounts/page.tsx` in order for it to work
you can also use
`/@sidebar/[...slug]/page.tsx` to catch all routes in the parallel side of the routing if you dont want to create duplicates for all sub pages
HavanaOP
I assume I can’t have a sidebar for all my routes? Or is the mental model I am not getting?
@Havana I assume I can’t have a sidebar for all my routes? Or is the mental model I am not getting?
you can have a side bar for all your routes by 2 ways:
either put it in
or put it in
either put it in
/layout.tsxor put it in
/@sidebar/[...slug]/page.tsxWestern thatching ant
The issue with this approach is it fails if you need to also have
So for instance:
The above does not work. So if you need parallel route which survives across all nav, there appears to be no way.
@sidebar rendered on the root page. Optional catchall routes are not supported with slots, you end up with an error.So for instance:
app/layout.tsx
app/page.tsx
app/foo/page.tsx
app/@navigation/[[...catchAll]]/page.tsxThe above does not work. So if you need parallel route which survives across all nav, there appears to be no way.
Western thatching ant
the issue tracking this bug is https://github.com/vercel/next.js/issues/61206