Files
upstream-mirror 3a013ccdfe
Some checks failed
autofix.ci / autofix (push) Failing after 4s
Release / Release (push) Has been skipped
GitHub Actions Security Analysis / Run zizmor (push) Failing after 2s
snapshot of https://github.com/TanStack/query.git (main, 2026-09-16; blobs > 131072B omitted)
2026-09-16 01:13:08 +05:00

1.5 KiB

id, title
id title
HydrationBoundary HydrationBoundary
function HydrationBoundary(__namedParameters): Element;

Defined in: packages/preact-query/src/HydrationBoundary.tsx:87

HydrationBoundary adds a previously dehydrated state into the queryClient that would be returned by useQueryClient(). If the client already contains data, the new queries will be intelligently merged based on update timestamp.

Note: Only queries can be dehydrated with an HydrationBoundary.

Parameters

__namedParameters

HydrationBoundaryProps

Returns

Element

The provided children, rendered unconditionally. New queries in state are hydrated into the cache during render; for queries already in the cache, only newer dehydrated data is hydrated, in an effect after commit.

Examples

import { HydrationBoundary } from '@tanstack/preact-query'

function App() {
  return <HydrationBoundary state={dehydratedState}>...</HydrationBoundary>
}

Server-side prefetch handed off to the client via dehydrate:

import { HydrationBoundary, dehydrate, noop } from '@tanstack/preact-query'

async function ServerComponent() {
  const queryClient = getQueryClient()

  await queryClient
    .query({
      queryKey: ['posts'],
      queryFn: fetchPosts,
    })
    .catch(noop)

  return (
    <HydrationBoundary state={dehydrate(queryClient)}>
      <Posts />
    </HydrationBoundary>
  )
}