What is the improvement or update you wish to see?
When template.json is designated as a Server Component, the server-side code executes only once for all routes that share the same template.
For instance, suppose there are /template.js, /a/page.js and /b/page.js files, and template.js is a Client Component. In such a case, navigating between /a/ and /b/ results in the execution of the template code. However, when /template.js is a Server Component (and does not render any additional Client Components), it functions similarly to layout.js
Is there any context that might help us understand?
If this behavior is intentional, it could be beneficial to include a mention in the documentation that, during navigation, only the client-side code of the template executes.
Does the docs page already exist? Please link to it.
What is the improvement or update you wish to see?
When template.json is designated as a Server Component, the server-side code executes only once for all routes that share the same template.
For instance, suppose there are
/template.js
,/a/page.js
and/b/page.js
files, andtemplate.js
is a Client Component. In such a case, navigating between/a/
and/b/
results in the execution of the template code. However, when/template.js
is a Server Component (and does not render any additional Client Components), it functions similarly tolayout.js
Is there any context that might help us understand?
If this behavior is intentional, it could be beneficial to include a mention in the documentation that, during navigation, only the client-side code of the template executes.
Does the docs page already exist? Please link to it.
https://nextjs.org/docs/app/api-reference/file-conventions/template