vercel / next.js

The React Framework
https://nextjs.org
MIT License
125.91k stars 26.87k forks source link

Docs: Unclear behavior on navigation with Server Component template.js #60633

Open aramikuto opened 9 months ago

aramikuto commented 9 months ago

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.

https://nextjs.org/docs/app/api-reference/file-conventions/template

rwieruch commented 5 months ago

Related to https://github.com/vercel/next.js/issues/60032 I guess