makeSyncBackend
makeSyncBackend(
__namedParameters):SyncBackendConstructor<{handle:string;offset:string; }>
Defined in: packages/@livestore/sync-electric/src/index.ts:195
Creates a sync backend that uses ElectricSQL for real-time event synchronization.
ElectricSQL enables real-time sync by streaming PostgreSQL changes to clients. This backend handles push (inserting events) and pull (streaming events via Electric’s shape-based sync protocol).
The endpoint should typically be part of your API layer to handle authentication, rate limiting, and proxying requests to the Electric server.
Parameters
Section titled “Parameters”__namedParameters
Section titled “__namedParameters”Returns
Section titled “Returns”SyncBackendConstructor<{ handle: string; offset: string; }>
Examples
Section titled “Examples”import { makeSyncBackend } from '@livestore/sync-electric'
const adapter = makePersistedAdapter({ sync: { backend: makeSyncBackend({ endpoint: '/api/electric', }), },})// With separate endpoints for push/pull/pingconst backend = makeSyncBackend({ endpoint: { push: '/api/push-event', pull: '/api/pull-events', ping: '/api/ping', }, ping: { enabled: true, requestInterval: 15_000, // 15 seconds },})https://livestore.dev/docs/sync/electric for setup guide