Overview

Streamsy is an Effect implementation of the Durable Streams protocol, with typed streams, projections, and hosts for Bun and Cloudflare.

Streamsy is an Effect implementation of the Durable Streams protocol.

import { Effect, Schema, Stream } from "effect";
import { MemoryStorage, Streamsy } from "@streamsy/core";

class Notes extends Streamsy.json<Notes>()("App/Notes", "notes", {
  params: {},
  schema: Schema.Struct({ text: Schema.String }),
}) {}

const program = Effect.gen(function* () {
  const notes = yield* Notes;
  yield* notes.create({});
  yield* notes.append({}, [{ text: "hello" }]);
  return yield* notes.read({}).pipe(
    Stream.flatMap((batch) => Stream.fromIterable(batch.items)),
    Stream.runCollect,
  );
});

await Effect.runPromise(program.pipe(Effect.provide(MemoryStorage.layer(Streamsy.group(Notes)))));

The stream class is a service key. The program asks for the service, and the Layer decides where the streams are kept.

Packages

PackageContents
@streamsy/coreStream classes, groups, the memory Layer, protocol routes, the remote Layer
@streamsy/storageSQLite storage for Bun and for Durable Objects
@streamsy/projectionCheckpointed projections over one or more streams
@streamsy/serveServe routes, Bun and Cloudflare hosts, and the action outbox

Sections

SectionContents
TutorialOne small application, from a stream to a deploy
StreamsDeclare, create, read, and write streams
ProjectionsDerive streams and state from other streams
HTTPProtocol routes, Serve routes, the remote client
HostingLayers, storage, Bun, and Cloudflare
DemosRunnable example applications

Effect runs on the server. In the browser, use the Durable Streams TypeScript client.

On this page