> ## 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.

# LiveStore

> Use S2 as a durable backend for LiveStore's event-sourced sync engine.

[LiveStore](https://livestore.dev) is a sync engine powered by event sourcing. The [`@livestore/sync-s2`](https://docs.livestore.dev/sync-providers/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

* An [S2 cloud account](https://s2.dev/sign-up)
* A scoped [access token](/concepts/access-tokens) for your basin

## Install

```bash theme={null}
pnpm add @livestore/sync-s2
```

Point the client's sync backend at your proxy endpoint:

```typescript theme={null}
import { makeSyncBackend } from '@livestore/sync-s2'

const backend = makeSyncBackend({
  endpoint: '/api/s2',
})
```

The proxy reads your S2 credentials from the environment:

```bash theme={null}
S2_BASIN=your_basin_name
S2_ACCESS_TOKEN=your_access_token
```

## Resources

* [LiveStore S2 sync provider](https://docs.livestore.dev/sync-providers/s2/) — full setup guide, including the API proxy implementation
* [LiveStore documentation](https://docs.livestore.dev)
