Durable Streams
Run the Durable Streams protocol locally and deploy it with Rivet.
Durable Streams is an open standard for real-time streams with durable, replayable history. Rivet provides an implementation backed by Rivet Actors.
Quickstart
Run locally
Standalone
Start the local Rivet control plane and the Durable Streams worker:
npx @rivet-dev/services dev
Durable Streams is available at http://127.0.0.1:8642/durable-streams/v1/stream/<path>.
RivetKit TypeScript SDK
Already running Rivet Actors with the RivetKit TypeScript SDK? Durable Streams is already available to you on RivetKit 2.3.12. No separate server needed.
Connect to a stream
TypeScript client
Install the official client:
npm install @durable-streams/client
import { DurableStream } from "@durable-streams/client";
const stream = await DurableStream.create({
url: "http://127.0.0.1:8642/durable-streams/v1/stream/demo",
contentType: "application/json",
});
await stream.append(JSON.stringify({ message: "hello" }));
// Read from the beginning, then keep receiving new messages live
const res = await stream.stream<{ message: string }>();
res.subscribeJson(async (batch) => {
for (const item of batch.items) console.log(item.message);
});
HTTP
Create a stream, append a record, and read its contents:
curl -i -X PUT \
-H 'content-type: application/json' \
--data '[{"message":"hello"}]' \
http://127.0.0.1:8642/durable-streams/v1/stream/demo
curl -i -X POST \
-H 'content-type: application/json' \
--data '{"message":"world"}' \
http://127.0.0.1:8642/durable-streams/v1/stream/demo
curl 'http://127.0.0.1:8642/durable-streams/v1/stream/demo?offset=-1'
Deploy
Rivet Cloud
- Sign up at the Rivet dashboard and create a new project.
- When creating the project, choose Durable Streams as the product.
- Point your Durable Streams client at the services URL you’re given, for example
https://xxxxx.rivet.run/durable-streams/.
Self-hosted
Run the Rivet Services node next to your own control plane. See Rivet Services.