ai-resumable-stream has 2,856 recorded weekly downloads on npm, an increase of 121% over the past 30 days, ranking #1756 of 3,247 tracked listings.
About ai-resumable-stream
ai-resumable-stream
<p align="center">AI SDK: Resume and stop UI message streams</p> <p align="center"> <a href="https://www.npmjs.com/package/ai-resumable-stream" alt="ai-resumable-stream"><img src="https://img.shields.io/npm/dt/ai-resumable-stream?label=ai-resumable-stream"></a> <a href="https://github.com/zirkelc/ai-resumable-stream/actions/workflows/ci.yml" alt="CI"><img src="https://img.shields.io/github/actions/workflow/status/zirkelc/ai-resumable-stream/ci.yml?branch=main"></a> </p> </div>This library provides resumable streaming for UI message streams created by streamText() in the AI SDK. The library stores chunks as they are produced. Clients can then resume an interrupted stream, and any request can stop an active stream.
You choose where the chunks are stored. The library includes adapters for Redis and S3 Express. You can also write your own adapter by implementing four methods.
Why?
A stream does not keep its data. After a chunk is sent, it is gone. This causes two problems.
Resume: The server does not record which chunks it has sent. When a client disconnects (network drop, page reload, tab switch), the stream continues on the server, but the client misses the chunks that are sent during that time. The server can only replay the missed chunks if they are stored somewhere.
Stop: The request that stops a stream is not the request that started it. When the user clicks "Stop generating", the client sends a new HTTP request, but the stream runs in a different request or process. The two requests need a shared place to pass the stop signal.
Install
npm install ai-resumable-stream
Install the optional peer dependencies for the features you use:
| Package | Needed for |
|---|---|
redis | ai-resumable-stream/adapters/redis |
@aws-sdk/client-s3 | ai-resumable-stream/adapters/s3-express |
ai | ai-resumable-stream/ai-sdk |
[!NOTE] Version compatibility:
- Use
ai-resumable-stream@1.xfor AI SDK v6- Use
ai-resumable-stream@2.xorai-resumable-stream@3.xand later for AI SDK v7
Quick start
Create one context and reuse it for every stream.
import { createClient } from "redis";
import { createRedisAdapter } from "ai-resumable-stream/adapters/redis";
import { createResumableUIMessageStream } from "ai-resumable-stream/ai-sdk";
const publisher = createClient({ url: process.env.REDIS_URL });
const subscriber = createClient({ url: process.env.REDIS_URL });
// Optional: connect clients immediately or let the library connect on demand
await publisher.connect();
await subscriber.connect();
const context = createResumableUIMessageStream({
adapter: createRedisAdapter({ publisher, subscriber }),
});
Then use the context in your three routes:
import { createUIMessageStreamResponse, streamText, toUIMessageStream, type UIMessage } from "ai";
// POST /chat/:chatId
export async function send(chatId: string, messages: Array<UIMessage>) {
const abortController = new AbortController();
const result = streamText({
model: openai(`gpt-4o`),
messages,
abortSignal: abortController.signal,
});
const { stream } = await context.startStream(toUIMessageStream({ stream: result.stream }), {
streamId: chatId,
abortController,
});
return createUIMessageStreamResponse({ stream });
}
// GET /chat/:chatId/stream
export async function resume(chatId: string) {
const stream = await context.resumeStream({ streamId: chatId });
if (!stream) return new Response(null, { status: 204 });
return createUIMessageStreamResponse({ stream });
}
// POST /chat/:chatId/stop
export async function stop(chatId: string) {
await context.stopStream({ streamId: chatId });
}
Usage
startStream
Starts a stream and stores the chunks as they are produced. Returns the stream for the client, the stream id and the generation id.
[!TIP] The returned stream is both a
ReadableStreamand an async iterable, soreturn streamandyield* streamboth work.
import { streamText, toUIMessageStream } from "ai";
async function sendMessage(chatId: string, messages: UIMessage[]) {
// Optional: `streamText` sees the stop signal and aborts the HTTP request
const abortController = new AbortController();
const result = streamText({
model: openai(`gpt-4o`),
messages,
abortSignal: abortController.signal,
});
const { stream } = await context.startStream(toUIMessageStream({ stream: result.stream }), {
// Optional: generates a stream id if not supplied
streamId: chatId,
abortController,
});
// Return stream to client
return stream;
}
```…
Description from the npm listing.
- ai
- ai-sdk
- redis
- resumable
- resumable-stream
- s3
- stream
README badge
Show your rank in a README or on your website. The badge updates automatically.
Charts
Images: 30d · 1y · all time · 1600×900 dark
Adoption over time
7/30/90-day growth
Ranking history
Listing placement
Listing placement
Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.
Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.
Recent observations
Full history (592)Similar npm AI SDKs plugins
All 20 ai-resumable-stream alternativesData source
Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.
Listing: https://www.npmjs.com/package/ai-resumable-stream. First seen Oct 16, 2026; last successful collection Dec 6, 2026. See the methodology.