Skip to content

Docs IA 2.0: Add examples to layout.js #79453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: canary
Choose a base branch
from

Conversation

delbaoliveira
Copy link
Contributor

@delbaoliveira delbaoliveira commented May 21, 2025

In the layout.js API reference, we talk about the limitations of layouts but don't provide alternative examples. This simplifies the wording, and adds examples using the recommended APIs.

Also adds more general layout.js examples.

Part of: https://linear.app/vercel/issue/DOC-4696/routing-section-layouts-and-templates

Follow up: Look into template.js

@ijjk ijjk added created-by: Next.js DevEx team PRs by the DX team. Documentation Related to Next.js' official documentation. labels May 21, 2025
Copy link

changeset-bot bot commented May 21, 2025

⚠️ No Changeset found

Latest commit: fbb31be

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

github-actions bot commented May 21, 2025

All broken links are now fixed, thank you!

@ijjk ijjk added the Font (next/font) Related to Next.js Font Optimization. label May 21, 2025
@delbaoliveira delbaoliveira changed the title Docs IA 2.0: Add examples to layout.js caveats Docs IA 2.0: Add examples to layout.js May 22, 2025

This performance optimization allows navigation between pages that share a layout to be quicker as only the data fetching and rendering for the page has to run, instead of the entire route that could include shared layouts that fetch their own data.
To access updated query parameters, you can use the Page[`searchParams`](/docs/app/api-reference/file-conventions/page#searchparams-optional) prop, or read them inside a Client Component using the [`useSearchParams`](/docs/app/api-reference/functions/use-search-params) hook. Since Client Components re-render on navigation, they have access to the latest query parameters.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
To access updated query parameters, you can use the Page[`searchParams`](/docs/app/api-reference/file-conventions/page#searchparams-optional) prop, or read them inside a Client Component using the [`useSearchParams`](/docs/app/api-reference/functions/use-search-params) hook. Since Client Components re-render on navigation, they have access to the latest query parameters.
To access updated query parameters, you can use the Page [`searchParams`](/docs/app/api-reference/file-conventions/page#searchparams-optional) prop, or read them inside a Client Component using the [`useSearchParams`](/docs/app/api-reference/functions/use-search-params) hook. Since Client Components re-render on navigation, they have access to the latest query parameters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
created-by: Next.js DevEx team PRs by the DX team. Documentation Related to Next.js' official documentation. Font (next/font) Related to Next.js Font Optimization.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants