ElectricSQL

website·Indexed 33 days ago

https://electric.ax/

A sync engine for Postgres that enables local-first applications through composable sync primitives. It provides a read-path sync engine for partial replication, a reactive client store via TanStack DB, and an embeddable Postgres database via PGlite. ElectricSQL supports multi-agent systems with durable event streams and offers integrations for React, Next.js, Expo, Elixir, and various cloud platforms like AWS, Fly.io, and Digital Ocean.

Tokens
156.2K
Snippets
649
Records
1.1K
Agent score
71%

What's inside ElectricSQL

  1. Overview of Electric Durable Streams

    Durable Streams provide a coordination model for multi-agent and multi-user systems. A durable stream is an addressable, append-only log with its own URL. Unlike ephemeral WebSockets or SSE, these streams are persistent and resumable over HTTP, allowing clients to read from any position in the log and tail for live updates. This pattern is referred to as 'Durable Sessions'.
  2. Overview of StreamDB

    StreamDB turns a Durable Stream into a reactive database. By providing a Standard Schema, developers get type-safe, multiplexed durable state with synchronization. It is designed for AI applications and agentic systems where state (tool calls, messages, presence) must be real-time, persistent, and forkable. StreamDB routes events by type into TanStack DB collections, using a differential dataflow engine for sub-millisecond reactivity.
  3. Overview of Electric Next sync engine

    Electric Next is a rebuild of the ElectricSQL sync engine. Unlike the previous version, which was a full local-first software platform, Electric Next is specifically a sync engine designed to sync data between Postgres and local clients (including apps, workers, services, and agents). It focuses on partial replication using 'Shapes' and provides a loosely coupled set of primitives rather than a vertical stack.
  4. Overview of Durable Streams client capabilities

    All official Durable Streams client libraries implement the same protocol and provide the following core capabilities:

    • Exactly-once writes: Uses IdempotentProducer with (producerId, epoch, seq) tuples for server-side deduplication, making retries safe after network errors.
    • Offset-based resumption: Clients can save the server-returned offset and provide it upon reconnection to resume streaming.
    • Live modes: Support for HTTP long-polling and Server-Sent Events (SSE) for real-time tailing (Note: PHP only supports long-polling).
    • JSON mode: Automatic array batching on writes and flattening on reads for JSON streams.
    • Automatic retries: Configurable exponential backoff for transient network and server errors.
  5. Overview of Linearlite local-first demo

    Linearlite is a project management application clone of Linear designed to demonstrate a fully-interactive, offline-capable app handling large datasets. It utilizes Electric for synchronization and PGlite as the local database to achieve fast initial data loading and instant local reactivity. Data writes are managed through DB sync with sophisticated merge logic.
  6. Overview of Electric Streams

    Electric Streams is a hosted, fully-managed implementation of the open Durable Streams protocol. It provides durable, append-only, replayable HTTP streams used for events, agent loops, and real-time data. A stream is essentially a URL that supports POST for appending events and GET for reading or replaying data from a specific offset. Streams are strictly ordered and CDN-cacheable.
  7. Overview of TanStack DB

    TanStack DB is a reactive client store that extends TanStack Query to enable local-first synchronization. It allows developers to build real-time, resilient applications by providing a local store interface that removes the network from the immediate interaction path. It is designed for incremental adoption, allowing developers to migrate existing API-based apps to a local-first architecture over time.
  8. Overview of Durable State

    Durable State provides structured state changes on top of Durable Streams. Instead of raw bytes, it uses a JSON-based protocol (Content-Type: application/json) to handle typed insert, update, and delete events. This allows developers to implement database-style sync semantics where clients append events to a stream and materialize the current state by applying them in order.
  9. Overview of Electric Circuits

    Electric Circuits is a primitive that converts static database queries into live result sets that update in real-time as the underlying database changes. It utilizes Incremental View Maintenance (IVM) via the DBSP engine, meaning it applies changes to the existing result set rather than re-running the entire query. Changes are delivered to clients via Durable Streams. The system is designed for fine-grained reactivity, ensuring clients only receive data relevant to what is being rendered.
  10. Overview of y-durable-streams Yjs provider

    The @durable-streams/y-durable-streams provider allows Yjs documents to be synced over HTTP using Durable Streams instead of traditional WebSocket relay servers. It utilizes a fan-out architecture where changes are written to a persistent, append-only log and synced via edge caches or CDNs. Key features include built-in persistence, automatic compaction of updates into immutable snapshots for fast client catch-up, and dedicated ephemeral awareness streams for real-time presence (with built-in TTL).
  11. Overview of Durable Proxy

    The @durable-streams/proxy package provides a proxy server that sits in front of existing AI streaming APIs. It forwards requests to an upstream provider, persists the streaming response into Durable Streams, and provides clients with a durable read URL. This allows clients to reconnect and resume reads if the connection is interrupted.
  12. Overview of Electric deployment architecture

    A successful Electric deployment consists of three main components: a Postgres database, the Electric sync service, and the application client. Electric connects to Postgres using a DATABASE_URL, and the application connects to Electric over HTTP, typically via a client library.