A collection of examples demonstrating streaming and resumable streaming patterns with tRPC, TanStack Query and AI SDK.
A basic example demonstrating how to use streaming with tRPC and TanStack Query.
This example implements resumable streaming with Vercel AI SDK on the server and client.
It uses the useChat hook from @ai-sdk/react and a custom ChatTransport implementation to connect with tRPC on the server.
The resumable streaming is managed by resumable-stream and Redis in-memory database.
This example builds on the AI SDK + tRPC example, but replaces the AI SDK's built-in useChat hook with a custom implementation using TanStack React Query for state management. It does not use @ai-sdk/react on the client.
This example demonstrates resumable streaming with multiple CLI clients using Redis for chunk persistence and pub/sub stop signaling via the resumable-stream library.
Same resumable streaming pattern as above, but replaces Redis with an in-memory SQLite database (Drizzle ORM). Chunks are flushed to SQLite in throttled batches, resume clients replay stored chunks then poll for new ones, and cancellation is detected via a cancelled_at field in the database.
Same resumable streaming pattern as Resumable Streaming with Redis, but the resumable streaming protocol is implemented inline against Redis pub/sub instead of using the resumable-stream library. Useful as a reference for understanding how the algorithm works end-to-end, and ships with an interactive TUI for stepping through producer/resumer flows under a debugger.
MIT