Params and Search in template.tsx #77098
CarrettaRiccardo
started this conversation in
Ideas
Replies: 0 comments
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.
-
EDIT: woops, might be duplicate of #46991
Goals
Add support for params and search params to
template.tsx
Non-Goals
Not intended to change behavior of current template.tsx: it currently supports being both a server component and client component
Background
I am using a new intl library (https://intlayer.org/) and the developer requires to put a server provider in each page, since it may change on a page-basis. Having this supported in a better way by the framework would be awesome (and probably lead to many new use cases)
As per documentation:
Official Next template.js file documentation
that means that theoretically template.tsx could support params and search params, since it's re-rendered on a page basis.
Pages
To access search params in Pages (Server Components), use the searchParams prop.
Layouts
Unlike Pages, Layouts (Server Components) do not receive the searchParams prop. This is because a shared layout is not re-rendered during navigation which could lead to stale searchParams between navigations. View detailed explanation.
Proposal
Add support for params and search params to
template.tsx
, as done for pagesBeta Was this translation helpful? Give feedback.
All reactions