Introduction
ElectricSQL provides a read-path sync layer for PostgreSQL that replicates data to client applications in real time. It uses Postgres logical replication under the hood and delivers partial, filtered data sets to clients over HTTP, enabling local-first architectures where reads are instant and work offline.
What ElectricSQL Does
- Streams filtered subsets of Postgres data to client applications in real time
- Enables local-first apps where reads come from a local cache with zero latency
- Syncs data bidirectionally between Postgres and connected clients
- Supports shape-based subscriptions to define exactly what data each client receives
- Works with any Postgres database without schema changes or extensions
Architecture Overview
ElectricSQL is built in Elixir and connects to PostgreSQL via logical replication. It reads the write-ahead log (WAL) and maintains a shape log that tracks which rows belong to which client subscription. Clients connect via HTTP streaming and receive an initial snapshot followed by incremental updates. The architecture separates the read path (Electric handles sync) from the write path (clients write directly to Postgres or through your API).
Self-Hosting & Configuration
- Deploy the Electric sync service as a Docker container alongside your Postgres instance
- Configure connection to any Postgres 14+ database via DATABASE_URL
- No Postgres extensions or plugins required; uses built-in logical replication
- Define shapes (data subsets) in your client code to control what syncs
- Horizontal scaling is supported by running multiple Electric instances behind a load balancer
Key Features
- Sub-second sync latency from Postgres to connected clients
- Shape-based partial replication keeps client data minimal and relevant
- Works with existing Postgres schemas without migrations or schema changes
- HTTP-based streaming protocol works through CDNs and standard infrastructure
- Client libraries available for TypeScript, React, and Expo
Comparison with Similar Tools
- Supabase Realtime — Broadcasts Postgres changes via WebSockets, but does not provide a local data cache or offline support
- Convex — Reactive backend with its own database; ElectricSQL works with your existing Postgres
- Firebase — Google-managed sync with proprietary NoSQL database, not Postgres-based
- PowerSync — Similar Postgres sync approach but closed-source server component
- CRDTs (Yjs, Automerge) — Document-level sync protocols; ElectricSQL syncs relational data at the row level
FAQ
Q: Does ElectricSQL replace my backend API? A: No. Electric handles the read-path sync. You keep your existing API for writes, authentication, and business logic.
Q: Can I use ElectricSQL with an existing Postgres database? A: Yes. ElectricSQL connects to any Postgres 14+ database using logical replication. No schema changes are needed.
Q: What happens when a client goes offline? A: The local cache continues to serve reads. When the client reconnects, Electric syncs the missed changes automatically.
Q: What is the license? A: Apache 2.0.