explaingit

electric-sql/electric

10,176TypeScriptAudience · developerComplexity · 3/5LicenseSetup · moderate

TLDR

Electric is a sync engine that streams live data from a PostgreSQL database to clients in real time over HTTP, so web apps and AI agents can work with a local copy of data that stays automatically up to date as the database changes.

Mindmap

mindmap
  root((Electric))
    What it does
      Sync Postgres to clients
      Real-time HTTP stream
      Local data copies
    Shapes
      Filter rows per client
      Reduce data transfer
    Client libraries
      TypeScript client
      React useShape hook
    Use Cases
      Real-time web apps
      AI agent data feeds
      CDN-scaled sync
    Setup
      Docker Compose
      Postgres logical replication
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Build a real-time web app where users see database changes instantly without polling, by syncing a filtered PostgreSQL table to the browser.

USE CASE 2

Give an AI agent a live local copy of database rows it needs to reason over, without querying the database on every step.

USE CASE 3

Distribute live database data to thousands of clients at scale by placing Electric's HTTP sync protocol behind a CDN.

USE CASE 4

Define per-client Shapes so each user receives only the rows they are allowed to see, rather than syncing entire tables.

Tech stack

TypeScriptPostgreSQLHTTPReactDocker

Getting it running

Difficulty · moderate Time to first run · 30min

PostgreSQL must have logical replication enabled, Docker Compose setup is provided for local development.

Free to use, modify, and distribute for any purpose including commercial use under the Apache 2.0 license, with attribution required.

In plain English

Electric is a sync engine for PostgreSQL databases. Its job is to copy data out of a Postgres database and deliver it to clients in real time, keeping everything up to date as the database changes. The problem it addresses is that modern applications, particularly those built for speed and offline use, often need their own local copy of data rather than fetching everything from a server on each request. Setting up that kind of sync from scratch is complex: you have to decide what data each client should receive, handle changes as they happen, and do all of this without overloading the database or the network. Electric handles these concerns so application developers do not have to. The core of Electric is an HTTP-based sync protocol. Clients request a stream of data using a simple HTTP call, and Electric pushes updates as they occur. Because it uses standard HTTP, the delivery layer can be placed behind a CDN for large-scale distribution. Developers who prefer not to work directly with the HTTP protocol can use client libraries for TypeScript or React hooks like useShape, which subscribe to a subset of a table and update automatically when data changes. The subset of data a client receives is defined using a concept called Shapes. Rather than syncing an entire table to every client, you define a Shape that filters to the rows relevant to that client, which keeps data transfer manageable. Electric is positioned for both web applications and AI agent systems that need to operate on live database data. It connects to Postgres via a standard database URL and requires logical replication to be enabled on the database. The project is licensed under Apache 2.0 and provides a Docker Compose setup for local development.

Copy-paste prompts

Prompt 1
Show me how to use Electric's useShape React hook to subscribe to a PostgreSQL 'messages' table and re-render a component whenever a row changes.
Prompt 2
I have a Postgres database and want to sync only the rows in an 'orders' table belonging to the logged-in user using Electric Shapes. Show me the HTTP request and TypeScript client setup.
Prompt 3
How do I set up Electric locally using Docker Compose and connect it to an existing PostgreSQL database with logical replication enabled?
Prompt 4
I'm building an AI agent that needs to read live rows from Postgres without hitting the database on every tool call. Show me how to use Electric to maintain a local data snapshot that updates automatically.
Prompt 5
Explain the difference between Electric Shapes and traditional WebSocket subscriptions for real-time data, when would I choose Electric over something like Supabase Realtime?
Open on GitHub → Explain another repo

← electric-sql on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.