Skip to main content
LiveStore is a sync engine powered by event sourcing. The @livestore/sync-s2 provider uses S2 as the durable backend for the event log — every client materializes state by replaying ordered events from an S2 stream.

How it works

Each LiveStore storeId maps to a single S2 stream. Events are JSON-serialized and appended as records, preserving their total order. Clients sync through a small API proxy that you run on your own server:
  • Client — the LiveStore client pushes and pulls events through your proxy endpoint.
  • API proxy — your server authenticates to S2, creates basins and streams as needed, and translates LiveStore sync operations into S2 API calls. The @livestore/sync-s2 package ships helpers for this, and is also where app-specific concerns like auth and rate limiting live.
  • S2 — stores the event log durably and streams live updates back to clients over SSE.

Prerequisites

Install

pnpm add @livestore/sync-s2
Point the client’s sync backend at your proxy endpoint:
import { makeSyncBackend } from '@livestore/sync-s2'

const backend = makeSyncBackend({
  endpoint: '/api/s2',
})
The proxy reads your S2 credentials from the environment:
S2_BASIN=your_basin_name
S2_ACCESS_TOKEN=your_access_token

Resources