-
Notifications
You must be signed in to change notification settings - Fork 30.9k
docs: add generateStaticParams to Cache Components migration guide #92382
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
Draft
aurorascharff
wants to merge
15
commits into
canary
Choose a base branch
from
docs/migrating-cache-components-generate-static-params
base: canary
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+103
−6
Draft
Changes from 2 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
8f55aea
docs: add generateStaticParams section to Cache Components migration …
aurorascharff b5fc405
Update for new build output
aurorascharff e9ee5f2
docs: tighten Cache Components migration route table copy
aurorascharff 8d94df7
docs: refine generateStaticParams build output notes in migration guide
aurorascharff 9272ae3
docs: tighten generateStaticParams migration section
aurorascharff 791ce09
docs: align migration guide with audit feedback
aurorascharff 22bfc57
docs: align Cache Components migration guide tone and structure
aurorascharff d4f7615
docs: soften generateStaticParams build output framing
aurorascharff 78769fc
docs: remove redundant checklist wording from migration guide
aurorascharff 8dd018a
docs: drop redundant PPR legend line in migration guide
aurorascharff b5987f7
Update with partialfallbacks default
aurorascharff 6f16850
Update
aurorascharff 71cac46
Simploify
aurorascharff 87e5246
Update
aurorascharff 9087828
docs: add inline comments to build output examples
aurorascharff File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -170,6 +170,70 @@ export default async function Page() { | |
| } | ||
| ``` | ||
|
|
||
| ## `generateStaticParams` | ||
|
|
||
| **Still supported.** Keep using [`generateStaticParams`](/docs/app/api-reference/functions/generate-static-params) for [dynamic routes](/docs/app/api-reference/file-conventions/dynamic-routes). With Cache Components, use [`generateStaticParams` with Cache Components](/docs/app/api-reference/functions/generate-static-params#with-cache-components) and [dynamic routes with Cache Components](/docs/app/api-reference/file-conventions/dynamic-routes#with-cache-components) as the source of truth for validation, Suspense, and unknown params. | ||
|
|
||
| If you previously used `return []`, that pattern becomes a [build error](/docs/messages/empty-generate-static-params); apply the fixes described in those docs (at least one sample param, or no `generateStaticParams` plus request-time patterns). | ||
|
|
||
| ```tsx filename="app/blog/[slug]/page.tsx" switcher | ||
| // Before | ||
| export async function generateStaticParams() { | ||
| return [] | ||
| } | ||
|
|
||
| export default async function Page({ | ||
| params, | ||
| }: { | ||
| params: Promise<{ slug: string }> | ||
| }) { | ||
| const { slug } = await params | ||
| return <div>{slug}</div> | ||
| } | ||
| ``` | ||
|
|
||
| ```jsx filename="app/blog/[slug]/page.js" switcher | ||
| // Before | ||
| export async function generateStaticParams() { | ||
| return [] | ||
| } | ||
|
|
||
| export default async function Page({ params }) { | ||
| const { slug } = await params | ||
| return <div>{slug}</div> | ||
| } | ||
| ``` | ||
|
|
||
| ```tsx filename="app/blog/[slug]/page.tsx" switcher | ||
| // After - Return at least one param (expand with your real slugs) | ||
| export async function generateStaticParams() { | ||
| return [{ slug: 'hello-world' }] | ||
| } | ||
|
|
||
| export default async function Page({ | ||
| params, | ||
| }: { | ||
| params: Promise<{ slug: string }> | ||
| }) { | ||
| const { slug } = await params | ||
| return <div>{slug}</div> | ||
| } | ||
| ``` | ||
|
|
||
| ```jsx filename="app/blog/[slug]/page.js" switcher | ||
| // After - Return at least one param (expand with your real slugs) | ||
| export async function generateStaticParams() { | ||
| return [{ slug: 'hello-world' }] | ||
| } | ||
|
|
||
| export default async function Page({ params }) { | ||
| const { slug } = await params | ||
| return <div>{slug}</div> | ||
| } | ||
| ``` | ||
|
|
||
| > **Good to know:** With Cache Components, each listed param shows its own symbol in the [build output](/docs/app/guides/building) — `○` if the page is fully static, or `◐` if it contains streamed content. See [Partial prerendering](/docs/app/guides/public-static-pages#partial-prerendering) for more details. | ||
|
||
|
|
||
| ## `runtime = 'edge'` | ||
|
|
||
| **Not supported.** Cache Components requires the Node.js runtime. Switch to the Node.js runtime (the default) by removing the `runtime = 'edge'` export. If you need edge behavior for specific routes, use [Proxy](/docs/app/api-reference/file-conventions/proxy) instead. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.