Skip to content

Commit 6d032c6

Browse files
committed
ppr
1 parent 2d87f90 commit 6d032c6

File tree

1 file changed

+41
-5
lines changed

1 file changed

+41
-5
lines changed

src/content/blog/2025/10/01/react-19-2.md

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,48 @@ See the [Component track docs](/reference/dev-tools/react-performance-tracks#com
151151
152152
### `resume` {/*resume*/}
153153
154-
We're adding new APIs to support partial pre-rendering for SSR:
154+
In 19.2 we're adding a new capability to pre-render part of the app ahead of time, and resume rendering it later.
155155
156-
- `resume`
157-
- `resumeToPipeableStream`
158-
- `resumeAndPrerender`
159-
- `resumeAndPrerenderToNodeStream`
156+
This feature is called "Partial Pre-rendering", and allows you to pre-render the static parts of your app and serve it from a CDN, and then resume rendering the shell to fill it in with dynamic content later.
157+
158+
To pre-render an app to resume later, first call `prerender` with an `AbortController`:
159+
160+
```
161+
const {prelude, postponed} = await prerender(<App />, {
162+
signal: controller.signal,
163+
});
164+
165+
// Save the postponed state for later
166+
await savePostponedState(postponed);
167+
168+
// Send prelude to client or CDN.
169+
```
170+
171+
Then, you can return the `prelude` shell to the client, and later call `resume` to "resume" to a SSR stream:
172+
173+
```
174+
const postponed = await getPostponedState(request);
175+
const resumeStream = await resume(<App />, postponed);
176+
177+
// Send stream to client.
178+
```
179+
180+
Or you can call `resumeAndPrerender` to resume to get static HTML for SSG:
181+
182+
```
183+
const postponedState = getPostponedState(request);
184+
const { prelude } = await resumeAndPrerender(<App />, postponedState);
185+
186+
// Send complete HTML prelude to CDN.
187+
```
188+
189+
For more info, see the docs for the new APIs:
190+
- `react-dom/server`
191+
- [`resume`](/reference/react-dom/server/resume): for Web Streams.
192+
- [`resumeToPipeableStream`](/reference/react-dom/server/resumeToPipeableStream) for Node Streams.
193+
- `react-dom/static`
194+
- [`resumeAndPrerender`](/reference/react-dom/static/resumeAndPrerender) for Web Streams.
195+
- [`resumeAndPrerenderToNodeStream`](/reference/react-dom/static/resumeAndPrerenderToNodeStream) for Node Streams.
160196
161197
Additionally, the prerender apis now return a `postpone` state to pass to the `resume` apis.
162198

0 commit comments

Comments
 (0)