Skip to content
Source
Sign inSign up
TanStack/db
Open History to see the last commit

db-hydration.tsx

23 lines569 Bytes

1'use client'
2​
3import { useState } from 'react'
4import { DbClient } from '@tanstack/db'
5import { DbProvider, HydrationBoundary } from '@tanstack/react-db'
6import type { DehydratedDbState } from '@tanstack/db'
7import type { ReactNode } from 'react'
8​
9export function DbHydration({
10 state,
11 children,
12}: {
13 state: DehydratedDbState
14 children: ReactNode
15}) {
16 const [client] = useState(() => new DbClient({ runtime: `browser` }))
17​
18 return (
19 <DbProvider client={client}>
20 <HydrationBoundary state={state}>{children}</HydrationBoundary>
21 </DbProvider>
22 )