Skip to main content
Version: v8.0.0

Hydrate

Hydrates the client cache with data fetched on the server.

  • Hooks below it render with the hydrated data on the first render, also during server rendering.
  • On the client the data is written to the cache before the hooks mount, so fresh data is not refetched.
  • Newer cache data is never replaced by an older snapshot.
  • It can be nested and rendered conditionally; every Hydrate serves only its own client.

Import
import { Hydrate } from "@hyper-fetch/react"

Props​

<Hydrate {...props} />
Parameters
NameTypeDescription
children
React.ReactNode

Children to render

client
ClientInstance

Client which cache receives the hydrated data

data
(HydrateDataType | EmptyTypes)[] | EmptyTypes

Dehydrated items, usually created on the server with request.dehydrate() . Empty values are ignored, so the list can be built conditionally.

options
HydrateOptionsType

Options applied to every item, as an object or a function of the item

Parameters​


children​

Children to render

React.ReactNode

client​

Client which cache receives the hydrated data

ClientInstance

data​

Dehydrated items, usually created on the server with request.dehydrate() . Empty values are ignored, so the list can be built conditionally.

(HydrateDataType | EmptyTypes)[] | EmptyTypes

options​

Options applied to every item, as an object or a function of the item

HydrateOptionsType