Skip to content

Yielded Sync

Shared state for Effect apps.

Keep clients in step with server state through live updates and typed actions.

Get startedWhy Sync?
bun add @yielded/sync@beta

Live demo

Three clients share one source with three seats.

  1. Alice reserves a seat. It shows at once, then the server commits #1 for everyone.
  2. Bob reserves, but his connection drops before the reply arrives.
  3. Bob reconnects and replays #2. Looking up b1 returns its receipt: one seat, not two.
  4. Alice and Carol race for the last seat. Carol lands first; Alice's prediction rolls back with SoldOut.

Live shared state

Clients receive the current state, follow changes, and catch up after a disconnect.

Typed actions

Define schemas for state, actions, and events. Your server decides which changes to accept.

Responsive edits

Show changes immediately while the server confirms them, and retry interrupted commands safely.

Define the source once. The server decides each reservation; clients predict it.

import { Action, Source } from "@yielded/sync";
import { Schema } from "effect";
export class SoldOut extends Schema.TaggedError<SoldOut>()("SoldOut", {}) {}
export const Seats = Source.make({
kind: "seats",
id: Schema.NonEmptyString.pipe(Schema.brand("ShowId")),
schemaVersion: 1,
snapshot: Schema.Struct({ seats: Schema.Array(Schema.NullOr(Schema.String)) }),
event: Schema.Struct({ seat: Schema.Int, guest: Schema.String }),
actions: [
Action.make("reserve", {
payload: Schema.Struct({ guest: Schema.String }),
success: Schema.Struct({ seat: Schema.Int }),
error: SoldOut,
}),
],
});

Your app supplies Principal and authorize in auth.ts. Step through each scenario to see how Sync handles conflicts, lost responses, and offline edits.

  1. Define a source.
  2. Connect a server.
  3. Connect a client.

For a complete application, run the React board.