examples/solid/streaming-solid-start2
| Name | Last commit message | Last commit date |
|---|---|---|
| .. | ||
README.md
TanStack Solid Query Streaming Example (SolidStart)#
Streaming SSR, with one route per case: prefetching, deferred and streamed queries, hydration, mixed queries, batch methods and errors.
Built with SolidStart.
How it works#
src/services/posts/queries.tsandsrc/services/users/queries.tsdefinepostsQueries.detail(...)andusersQueries.detail(...)withqueryOptions. TheirsleepandsimulateErrorarguments are part of thequeryKeyand are passed tosrc/services/posts/api.tsandsrc/services/users/api.tsto add latency or throw.src/components/user-info.tsxandsrc/components/post-viewer.tsxread the data withuseQueryand forward adeferStreamprop.src/components/query-boundary.tsxwraps a query result in<Suspense>and anErrorBoundarywith a retry button that callsrefetch.src/routes/streamed.tsxstreams each query's result to the client when it resolves on the server, whilesrc/routes/deferred.tsxandsrc/routes/with-error.tsxsetdeferStreamso the server waits for those queries before it sends HTML.src/routes/mixed.tsxsetsdeferStreamonly on the quickUserInfoquery, so its HTML waits for that query whilePostViewerstreams in afterward.src/routes/prefetch.tsxstarts the user query in the route'spreloadwithqueryClient.query(...), andsrc/routes/hydration.tsxcompares the query state on the server, right after hydration and on the client.src/routes/batch-methods.tsxswitches the scheduler used to batch updates withnotifyManager.setScheduler.
To run this example:
npm installnpm run dev