Unverified Commit 69f53fd9 authored by Joseph's avatar Joseph Committed by GitHub

docs: Streaming guide (#90779)

- [x] update links to demo
- [x] minor polishing identified by AI
- [x] update links (dep: docs-unify-caching-story)
- [x] check the implementation details vs actionable info balance
- [x] how (and when) to block streaming?
https://github.com/vercel/next.js/pull/90450
- [x] INP and the hydrate me later trick link to demo

---------
Co-authored-by: 's avatarDelba de Oliveira <32464864+delbaoliveira@users.noreply.github.com>
parent 3162af8d
...@@ -99,7 +99,7 @@ To improve the navigation experience to dynamic routes, you can use [streaming]( ...@@ -99,7 +99,7 @@ To improve the navigation experience to dynamic routes, you can use [streaming](
### Streaming ### Streaming
Streaming allows the server to send parts of a dynamic route to the client as soon as they're ready, rather than waiting for the entire route to be rendered. This means users see something sooner, even if parts of the page are still loading. Streaming allows the server to send parts of a dynamic route to the client as soon as they're ready, rather than waiting for the entire route to be rendered. This means users see something sooner, even if parts of the page are still loading. See the [Streaming guide](/docs/app/guides/streaming) for a deep dive into how streaming works in Next.js.
For dynamic routes, it means they can be **partially prefetched**. That is, shared layouts and loading skeletons can be requested ahead of time. For dynamic routes, it means they can be **partially prefetched**. That is, shared layouts and loading skeletons can be requested ahead of time.
......
...@@ -101,7 +101,7 @@ You should still ensure requests are properly authenticated and authorized. For ...@@ -101,7 +101,7 @@ You should still ensure requests are properly authenticated and authorized. For
When you fetch data in Server Components, the data is fetched and rendered on the server for each request. If you have any slow data requests, the whole route will be blocked from rendering until all the data is fetched. When you fetch data in Server Components, the data is fetched and rendered on the server for each request. If you have any slow data requests, the whole route will be blocked from rendering until all the data is fetched.
To improve the initial load time and user experience, you can break the page into smaller _chunks_ and progressively send those chunks from the server to the client. This is called streaming. To improve the initial load time and user experience, you can break the page into smaller _chunks_ and progressively send those chunks from the server to the client. This is called streaming. See the [Streaming guide](/docs/app/guides/streaming) for a deeper look at how streaming works, including the HTTP contract, infrastructure considerations, and performance trade-offs.
<Image <Image
alt="How Server Rendering with Streaming Works" alt="How Server Rendering with Streaming Works"
......
...@@ -17,7 +17,7 @@ There are two ways you can implement lazy loading in Next.js: ...@@ -17,7 +17,7 @@ There are two ways you can implement lazy loading in Next.js:
1. Using [Dynamic Imports](#nextdynamic) with `next/dynamic` 1. Using [Dynamic Imports](#nextdynamic) with `next/dynamic`
2. Using [`React.lazy()`](https://react.dev/reference/react/lazy) with [Suspense](https://react.dev/reference/react/Suspense) 2. Using [`React.lazy()`](https://react.dev/reference/react/lazy) with [Suspense](https://react.dev/reference/react/Suspense)
By default, Server Components are automatically [code split](https://developer.mozilla.org/docs/Glossary/Code_splitting), and you can use [streaming](/docs/app/api-reference/file-conventions/loading) to progressively send pieces of UI from the server to the client. Lazy loading applies to Client Components. By default, Server Components are automatically [code split](https://developer.mozilla.org/docs/Glossary/Code_splitting), and you can use [streaming](/docs/app/guides/streaming) to progressively send pieces of UI from the server to the client. Lazy loading applies to Client Components.
## `next/dynamic` ## `next/dynamic`
......
...@@ -205,7 +205,7 @@ The scheduler prioritizes likely navigations while minimizing unused downloads. ...@@ -205,7 +205,7 @@ The scheduler prioritizes likely navigations while minimizing unused downloads.
### Partial Prerendering (PPR) ### Partial Prerendering (PPR)
When PPR is enabled, a page is divided into a static shell and a streamed dynamic section: When PPR is enabled, a page is divided into a [static shell](/docs/app/guides/streaming#the-static-shell) and a streamed dynamic section:
- The shell, which can be prefetched, streams immediately - The shell, which can be prefetched, streams immediately
- Uncached data streams when ready - Uncached data streams when ready
......
This diff is collapsed.
...@@ -140,7 +140,7 @@ Learn how to [configure streaming](/docs/app/guides/self-hosting#streaming-and-s ...@@ -140,7 +140,7 @@ Learn how to [configure streaming](/docs/app/guides/self-hosting#streaming-and-s
### Streaming with Suspense ### Streaming with Suspense
In addition to `loading.js`, you can also manually create Suspense Boundaries for your own UI components. The App Router supports streaming with [Suspense](https://react.dev/reference/react/Suspense). In addition to `loading.js`, you can also manually create Suspense Boundaries for your own UI components. The App Router supports streaming with [Suspense](https://react.dev/reference/react/Suspense). See the [Streaming guide](/docs/app/guides/streaming) for more on how streaming works, including granular Suspense patterns, Route Handler streaming, and infrastructure considerations.
`<Suspense>` works by wrapping a component that performs an asynchronous action (e.g. fetch data), showing fallback UI (e.g. skeleton, spinner) while it's happening, and then swapping in your component once the action completes. `<Suspense>` works by wrapping a component that performs an asynchronous action (e.g. fetch data), showing fallback UI (e.g. skeleton, spinner) while it's happening, and then swapping in your component once the action completes.
......
...@@ -247,7 +247,7 @@ The prerendered HTML structure of a page that's served immediately to the browse ...@@ -247,7 +247,7 @@ The prerendered HTML structure of a page that's served immediately to the browse
## Streaming ## Streaming
A technique that allows the server to send parts of a page to the client as they become ready, rather than waiting for the entire page to render. Enabled automatically with [`loading.js`](/docs/app/api-reference/file-conventions/loading) or manual `<Suspense>` boundaries. Learn more in [Linking and Navigating - Streaming](/docs/app/getting-started/linking-and-navigating#streaming). A technique that allows the server to send parts of a page to the client as they become ready, rather than waiting for the entire page to render. Enabled automatically with [`loading.js`](/docs/app/api-reference/file-conventions/loading) or manual `<Suspense>` boundaries. Learn more in the [Streaming guide](/docs/app/guides/streaming).
## Suspense boundary ## Suspense boundary
......
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