Replies: 11 comments 16 replies
-
I am also facing this issue in the context of a multi-language website, where most of the content is available under a
Ideally you'd want a single layout in this situation:
and the root layout can display UI elements in the appropriate language. But because I had to do this kind of workaround:
But this is bad because |
Beta Was this translation helpful? Give feedback.
-
I also think params should be there on all levels, right now one have to parse urls manually to get the params at a higher level layout. Lets say i want to build breadcrums i am missing this info |
Beta Was this translation helpful? Give feedback.
-
Even if a layout is not meant to be rerendered, this seems important to have access to all params in any layout if any initial component rendering depends on a child param. We have currently no workaround to deal with this server side without accessing headers (which would make the layout dynamic and slow). |
Beta Was this translation helpful? Give feedback.
-
How do folks build breadcrumbs in a layout at the top level if there are multiple layers of dynamic routes? |
Beta Was this translation helpful? Give feedback.
-
The pattern I'm using is to have a client component inside layout which changes based on
The unfortunate consequence of this is that I would have to do API calls in the client component to gather necessary data (which I do using server actions), and I cannot pre-fetch those data in the server component (or layout.js) and pass it down to client as props. The latter is preferred, but only possible in pages or nested layouts (with access to params). If you do use Server Actions to abstract your API calls, then you can write an action that returns the bare minimum data needed instead of all the data from backend. |
Beta Was this translation helpful? Give feedback.
-
Well, still no changes on this issue. Have the same issue where I need to access a params in my top level layout. |
Beta Was this translation helpful? Give feedback.
-
We're also struggling with this. +1 to making access to search params in the layout opt in. Those that opt out can receive the optimizations and those that don't, don't need to create page wrappers and proxy params to capture this server-side functionality. |
Beta Was this translation helpful? Give feedback.
-
Let me share my implementation method [lang]
|
Beta Was this translation helpful? Give feedback.
-
i mean layout should be some kinda middleware for it's nested childs thus it should have all the query state ? any solution here ? |
Beta Was this translation helpful? Give feedback.
-
I double this problem. layout should have access to all the possible parameters |
Beta Was this translation helpful? Give feedback.
-
Just came across this problem and was able to solve it using a Client Component inside the layout. The Client Component will update its usePathname() on navigation, but not cause blips on the screen. |
Beta Was this translation helpful? Give feedback.
-
Describe the feature you'd like to request
Currently, a layout component only receives params for the route segments "from the root segment down to that layout". However, there are many common patterns where a higher-level layout may need to know all of the dynamic segments, for example, breadcrumb links in a global header or footer. The Vercel web app is a good example: it uses a global top-bar with breadcrumb-like links that update as the user drills down into their deployments.
Ex:
This would be simple to do if the root-level layout were given all of the dynamic route params, but is (maybe?) impossible to do without it.
Describe the solution you'd like
All layout components should receive the complete set of
params
for the route being rendered, regardless of where they are in the file tree.Today, when rendering
/[groupId]/[itemId]
:app/layout.js
{}
app/[groupId]/layout.js
{ groupId: "…" }
app/[groupId]/[itemId]/layout.js
{ groupId: "…", itemId: "…" }
Proposed, when rendering
/[groupId]/[itemId]
:app/layout.js
{ groupId: "…", itemId: "…" }
app/[groupId]/layout.js
{ groupId: "…", itemId: "…" }
app/[groupId]/[itemId]/layout.js
{ groupId: "…", itemId: "…" }
I suspect this may de-optimize some caching or streaming being done for layouts, as the higher-level layouts would now need to be re-computed more often, but the alternative (described below) is that a developer will have to forego the nested layouts anyways. Perhaps it can be opted in to?
Describe alternatives you've considered
In order to do breadcrumb links (and other common nav patterns that rely on the full route) in layouts right now, you have to NOT use nested layouts, and instead provide redundant layout files at all of the leaf-nodes of your file tree, or skip layouts altogether and just render pages with redundant global components.
Beta Was this translation helpful? Give feedback.
All reactions