-
I followed the docs to access the searchParams (Docs) in my server component. However, I also need access to the Is there a way to use |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Due to the way Next.js renders a layout tree, and passes the The only case where this might work (no guarantees) is if:
For point 1, layouts outside of a dynamic segment would be statically built once, and so would not be rendered per-page. For point 2, it's possible that React would render the components that need to consume the cache before the page is rendered and had a chance to populate it (not entirely sure about this one). |
Beta Was this translation helpful? Give feedback.
See an example in #573.
You can even access params in parent layouts above the
[dynamic]
route, as long as you take care of handling errors thrown by the cache (for cousin pages that are not under the[dynamic]
path fragment). Whether or not you want to do this is a questionable architecture decision 😅