Unverified Commit c3d1e893 authored by Joseph's avatar Joseph Committed by GitHub

docs: runtime prefetching update (#95564)

Sync the runtime prefetching guide with latest App Shell changes
parent 4a4590a3
...@@ -83,7 +83,7 @@ export default function CategoryLayout(props: LayoutProps<'/[category]'>) { ...@@ -83,7 +83,7 @@ export default function CategoryLayout(props: LayoutProps<'/[category]'>) {
} }
``` ```
Notice that `CategoryLayout` does not `await props.params` itself. Instead, it passes the `params` promise to `CategoryHeader` inside `<Suspense>`. The `await` happens inside the boundary, so for unknown categories Next.js can still generate the App Shell. Notice that `CategoryLayout` does not `await props.params` itself. Instead, it passes the `params` promise to `CategoryHeader` inside `<Suspense>`. The `await` happens inside the boundary, so for unknown categories Next.js can still generate the App Shell. Keep the read inside the boundary even for the categories `generateStaticParams` covers. A statically known param still belongs to one URL, so awaiting it above the Suspense boundary would tie this layout's App Shell to that URL. See [Instant navigation](/docs/app/guides/instant-navigation) for structuring routes this way.
The product page prerenders one product per category. `generateStaticParams` receives the parent `category` param: The product page prerenders one product per category. `generateStaticParams` receives the parent `category` param:
......
...@@ -50,7 +50,7 @@ With Cache Components, **caching directives** (`"use cache"` and its variants) a ...@@ -50,7 +50,7 @@ With Cache Components, **caching directives** (`"use cache"` and its variants) a
> **Good to know:** A fallback may access `cookies()`, `headers()`, or the full URL. At build time, the fallback itself suspends, and a `<Suspense>` boundary further up the tree is needed. With [runtime prefetching](/docs/app/guides/runtime-prefetching), the information is available and such a fallback becomes part of the instant UI. Cached values like timestamps or data fetches can sit directly inside the fallback. > **Good to know:** A fallback may access `cookies()`, `headers()`, or the full URL. At build time, the fallback itself suspends, and a `<Suspense>` boundary further up the tree is needed. With [runtime prefetching](/docs/app/guides/runtime-prefetching), the information is available and such a fallback becomes part of the instant UI. Cached values like timestamps or data fetches can sit directly inside the fallback.
Next.js can also generate an [**App Shell**](/docs/app/glossary#app-shell) per route: a fallback that renders instantly during client navigations when nothing else is ready. See [App Shells](/docs/app/guides/runtime-prefetching#app-shells) for how to enable them and how they pair with runtime prefetching. Next.js can also generate an [**App Shell**](/docs/app/glossary#app-shell) per route: a fallback that renders instantly during client navigations when nothing else is ready. [Runtime prefetching](/docs/app/guides/runtime-prefetching) builds on it, resolving a link's URL data on top.
### Tune what `<Link>` prefetches ### Tune what `<Link>` prefetches
......
...@@ -205,13 +205,15 @@ Next.js maintains a small task queue, which prefetches in the following order: ...@@ -205,13 +205,15 @@ Next.js maintains a small task queue, which prefetches in the following order:
The scheduler prioritizes likely navigations while minimizing unused downloads. The scheduler prioritizes likely navigations while minimizing unused downloads.
### Partial Prerendering (PPR) ### Cache Components
When PPR is enabled, a page is divided into a [static shell](/docs/app/guides/streaming#the-static-shell) and a streamed dynamic section: With [Cache Components](/docs/app/getting-started/caching) enabled, the prefetching strategy uses an [App Shell](/docs/app/glossary#app-shell) to make client navigations instant:
- The shell, which can be prefetched, streams immediately - The App Shell holds the route's static and session output.
- Uncached data streams when ready - Uncached data streams in when ready.
- Data invalidations (`revalidateTag`, `revalidatePath`) silently refresh associated prefetches - Data invalidations (`revalidateTag`, `revalidatePath`) silently refresh associated prefetches.
A link can also resolve its URL data (`searchParams`, `params`) at prefetch time. See [Runtime prefetching](/docs/app/guides/runtime-prefetching).
## Troubleshooting ## Troubleshooting
......
...@@ -50,7 +50,7 @@ With `partialPrefetching: true`, Next.js prefetches one reusable [App Shell](/do ...@@ -50,7 +50,7 @@ With `partialPrefetching: true`, Next.js prefetches one reusable [App Shell](/do
The pattern is similar to per-route code splitting in single-page apps: one artifact per route, shared by every link that points to it. The pattern is similar to per-route code splitting in single-page apps: one artifact per route, shared by every link that points to it.
> **Good to know**: Routes that read `cookies()` or `headers()` produce an App Shell that includes session data. The framework auto-detects this, and the shell is cached per session on the client, not shared across users. > **Good to know**: Routes that read `cookies()` or `headers()` produce an App Shell that includes session data. The framework auto-detects this and caches the shell per session on the client.
A link can ask for more than the App Shell with [`<Link prefetch={true}>`](/docs/app/api-reference/components/link#prefetch). If the destination opts into [`prefetch = 'allow-runtime'`](/docs/app/api-reference/file-conventions/route-segment-config/prefetch#allow-runtime), the prefetch also resolves per-link runtime data like `params`, `searchParams`, and the full URL. A link can ask for more than the App Shell with [`<Link prefetch={true}>`](/docs/app/api-reference/components/link#prefetch). If the destination opts into [`prefetch = 'allow-runtime'`](/docs/app/api-reference/file-conventions/route-segment-config/prefetch#allow-runtime), the prefetch also resolves per-link runtime data like `params`, `searchParams`, and the full URL.
......
...@@ -12,7 +12,7 @@ The Next.js router introduced in version 13, built on top of React Server Compon ...@@ -12,7 +12,7 @@ The Next.js router introduced in version 13, built on top of React Server Compon
## App Shell ## App Shell
A per-route prerender containing the parts of a page that don't depend on URL-specific data. Routes that read `cookies()` or `headers()` produce a session-personalized variant, cached per session on the client. Used as the prefetch payload during client navigations, the loading state during [runtime prefetching](/docs/app/guides/runtime-prefetching), and the fallback for [ISR with Cache Components](/docs/app/guides/incremental-static-regeneration-cache-components). A per-route prerender containing the parts of a page that don't depend on URL data. Routes that read `cookies()` or `headers()` produce one that also includes session data, cached per session on the client. Used as the prefetch payload during client navigations, the loading state during [runtime prefetching](/docs/app/guides/runtime-prefetching), and the fallback for [ISR with Cache Components](/docs/app/guides/incremental-static-regeneration-cache-components).
# B # B
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment