> ## Documentation Index
> Fetch the complete documentation index at: https://s2.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Sync

> Use S2 as the shared log for multiplayer apps and data sync, with ordered history that clients and services can replay whenever they need to catch up.

S2 streams can serve as the shared log that keeps data in sync — between clients, between services, or between databases and downstream consumers.

## Event sourcing

Store events instead of current state. Append each change to a stream, and materialize state by replaying from the beginning — or from a [checkpoint](/concepts/snapshots). New consumers can be added at any time by reading the full history.

S2's [strong consistency](/concepts/reads#consistency) and [durable total ordering of records](/concepts/streams) make it a natural fit as a shared write-ahead log.

See the [kv-store blog post](https://s2.dev/blog/kv-store) for a detailed example of how a replicated database with strong consistency can be built directly over the S2 primitive.

## WebSockets alternative

S2 streams can replace stateful WebSocket connections for bidirectional communication. Use two streams (one per direction) or a single shared stream. Records are durable and ordered, clients can reconnect and resume from their last sequence number, and there's no connection state to manage server-side.

## Related integrations

<CardGroup cols={2}>
  <Card title="Y-S2" href="/integrations/y-s2">
    Build Yjs collaborative editing on S2 streams.
  </Card>

  <Card title="Sequin" href="/integrations/sequin">
    Stream Postgres CDC changes into S2.
  </Card>

  <Card title="LiveStore" href="/integrations/livestore">
    Use S2 as a durable sync backend for LiveStore.
  </Card>
</CardGroup>
