You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* updated docs on SSR
Hydrate -> HydrationBoundary
* docs(ssr): change Hydrate->HydrationBoundary
change Hydrate->HydrationBoundary to remove deprecated component
* docs(ssr): rename all Hydrate->HydrationBoundary
rename all Hydrate instances ->HydrationBoundary for consistency
Copy file name to clipboardExpand all lines: docs/react/guides/ssr.md
+14-11Lines changed: 14 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -302,19 +302,19 @@ ReactDOM.hydrate(
302
302
303
303
## Using the `app` Directory in Next.js 13
304
304
305
-
Both prefetching approaches, using `initialData` or `<Hydrate>`, are available within the `app` directory.
305
+
Both prefetching approaches, using `initialData` or `<HydrationBoundary>`, are available within the `app` directory.
306
306
307
307
- Prefetch the data in a Server Component and prop drill `initialData` to Client Components
308
308
- Quick to set up for simple cases
309
309
- May need to prop drill through multiple layers of Client Components
310
310
- May need to prop drill to multiple Client Components using the same query
311
311
- Query refetching is based on when the page loads instead of when the data was prefetched on the server
312
-
- Prefetch the query on the server, dehydrate the cache and rehydrate it on the client with `<Hydrate>`
312
+
- Prefetch the query on the server, dehydrate the cache and rehydrate it on the client with `<HydrationBoundary>`
313
313
- Requires slightly more setup up front
314
314
- No need to prop drill
315
315
- Query refetching is based on when the query was prefetched on the server
316
316
317
-
### `<QueryClientProvider>` is required by both the `initialData` and `<Hydrate>` prefetching approaches
317
+
### `<QueryClientProvider>` is required by both the `initialData` and `<HydrationBoundary>` prefetching approaches
318
318
319
319
The hooks provided by the `react-query` package need to retrieve a `QueryClient` from their context. Wrap your component tree with `<QueryClientProvider>` and pass it an instance of `QueryClient`.
320
320
@@ -379,7 +379,7 @@ export function Posts(props) {
379
379
}
380
380
```
381
381
382
-
### Using `<Hydrate>`
382
+
### Using `<HydrationBoundary>`
383
383
384
384
Create a request-scoped singleton instance of `QueryClient`. **This ensures that data is not shared between different users and requests, while still only creating the QueryClient once per request.**
385
385
@@ -397,30 +397,33 @@ Fetch your data in a Server Component higher up in the component tree than the C
397
397
- Retrieve the `QueryClient` singleton instance
398
398
- Prefetch the data using the client's prefetchQuery method and wait for it to complete
399
399
- Use `dehydrate` to obtain the dehydrated state of the prefetched queries from the query cache
400
-
- Wrap the component tree that needs the prefetched queries inside `<Hydrate>`, and provide it with the dehydrated state
401
-
- You can fetch inside multiple Server Components and use `<Hydrate>` in multiple places
400
+
- Wrap the component tree that needs the prefetched queries inside `<HydrationBoundary>`, and provide it with the dehydrated state
401
+
- You can fetch inside multiple Server Components and use `<HydrationBoundary>` in multiple places
402
402
403
403
> NOTE: TypeScript currently complains of a type error when using async Server Components. As a temporary workaround, use `{/* @ts-expect-error Server Component */}` when calling this component inside another. For more information, see [End-to-End Type Safety](https://beta.nextjs.org/docs/configuring/typescript#end-to-end-type-safety) in the Next.js 13 beta docs.
During server rendering, calls to `useQuery` nested within the `<Hydrate>` Client Component will have access to prefetched data provided in the state property.
426
+
During server rendering, calls to `useQuery` nested within the `<HydrationBoundary>` Client Component will have access to prefetched data provided in the state property.
0 commit comments