Parameters to layout.tsx #45023
edwinvelez
started this conversation in
Ideas
Replies: 1 comment
-
I have the same issue right now. I want to pass parameters to layout.tsx to conditionally render a sidebar's nav menu items based on arguments from page.tsx. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
With Next.js 13, is it possible to interact directly with
layout.tsx
? If not, I think this would be a nice feature to have. Someone else also has a similar issue.DISCLAIMER: I have left similar notes leading up to this discussion on the Beta documentation.
I know I can create Nested Layouts and Multiple Root Layouts.
What though if I wanted to selectively show a component defined in
/layout.tsx
? For example, I want<Navbar />
to show on most pages but not all i.e. anything inheritied fromlayout.tsx
but not on/dashboard/page.tsx
that has its ownlayout.tsx
file. I could also have a landing page where I do not want the<Navbar />
shown. If/layout.tsx
were to accept parameters, it could help simplify (or maybe even eliminate) the use of Nested and Multiple Root Layouts. It would definitely clean up lines of code which may become repitive depending on how manylayout.tsx
files exist in the project.Would this also contribute to reducing page render counts? I admit, I am not 100% fully confident in how it exactly works with Next 13. Going back to the example of
<Navbar />
, when changing between/dashboard/page.tsx
and/page.tsx
. This would be two page renders between routes correct for eachlayout.tsx
? But if it accepted parameters and<Navbar />
was conditionally shown in a singlelayout.tsx
file, would this help in that count?Beta Was this translation helpful? Give feedback.
All reactions