Open History to see the last commit
1import { Suspense } from 'react'
2import { DbClient } from '@tanstack/db'
3import { DbHydration } from './db-hydration'
4import { streamedTodoQuery } from './ssr-fixture'
5import { StreamedTodos } from './streamed-todos'
6
7export const dynamic = `force-dynamic`
8
9export default function Page() {
10 const dbClient = new DbClient({ runtime: `server` })
11 void dbClient.preloadLiveQuery(streamedTodoQuery)
12 const state = dbClient.dehydrate({
13 shouldDehydrateCollection: () => false,
14 shouldDehydrateLiveQuery: () => true,
15 })
16
17 return (
18 <main>
19 <h1>TanStack DB Next.js SSR</h1>
20 <DbHydration state={state}>
21 <Suspense fallback={<p data-testid="stream-fallback">Loading todos</p>}>
22 <StreamedTodos />
23 </Suspense>
24 </DbHydration>
25 </main>
26 )
27}