Skip to main content
Streams

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" }));

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

  1. Sign up at the Rivet dashboard and create a new project.
  2. When creating the project, choose Durable Streams as the product.
  3. 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 control plane with the required feature flags enabled:

docker run -p 6420:6420 \
  -e RIVET__FEATURES__GUARD_GATEWAY_V3__MODE=on \
  -e RIVET__FEATURES__GUARD_GATEWAY_V3__PERCENTAGE=100 \
  rivetdev/engine

See the self-hosting guides for other ways to run it.

Run the Durable Streams worker. It runs your streams and connects to the control plane:

docker run -p 8642:8642 \
  --add-host=host.docker.internal:host-gateway \
  -e RIVET_ENDPOINT=http://host.docker.internal:6420 \
  -e HOST=0.0.0.0 \
  rivetdev/services

Your streams are at http://<host>:8642/durable-streams/v1/stream/<path>.