Sync with your stack
Electric provides composable sync primitives.
This allows you to add real-time sync to your existing stack, without imposing technology choices, code changes or data silos.
Sync stacks
We've picked four different sync stacks to illustrate four different ways of integrating Electric into your stack of choice.
TanStack
End-to-end Typescript, syncing through server functions into TanStack DB. Great for super fast web, mobile and AI app development.
Great for super fast web, mobile and AI app development.
Postgres
Electric
TypeScript
Cloudflare
TanStack
Phoenix
Sync through a batteries-included backend framework using Phoenix.Sync. Great for agentic systems and full-stack development.
Great for agentic systems and full-stack development.
Postgres
Electric
Phoenix
TanStack
PGlite
Syncing data into an embedded Postgres database using PGlite. Great for dev, test and sandbox environments.
Great for dev, test and sandbox environments.
Postgres
Electric
PGlite
Yjs
Crafting conflict-free, multi-user applications with Electric and Yjs. Great for fine-tuned realtime collaboration.
Great for fine-tuned realtime collaboration.
Postgres
Electric
Yjs
Core architecture
All of these sync stacks are based on the same core architecture.
Electric always runs as a service in front of Postgres, syncing into a Client process or store, via a Proxy or backend API.


You can learn more about these by following Deployment guide.
Choosing a stack
We recommend using TanStack DB for web and mobile app development. It's super fast, lightweight, type-safe and gives you an optimal, end-to-end, local-first sync stack.
You can also combine TanStack DB with Phoenix.Sync if you're building agentic systems with Elixir or looking for a batteries-included backend framework.
PGlite and Yjs are more for specialist use-cases where you're syncing into a dev, test or CI environment or crafting a multi-user collaboration system, respectively.
Choosing a Postgres host
Electric works with any Postgres with logical replication enabled. Neon, Supabase and Crunchy are all great choices for a Postgres host.
Hosting your proxy
You can proxy requests to Electric either through your backend API, or through a cloud worker. Cloudflare is a great choice for hosting workers because it only charges for actual processing time (not for wall clock time holding sync connections open).
Other stacks
The stacks on this page are just some options and recommendations. You can use Electric with any technology you like — as long as it speaks HTTP and JSON.
For example, sync into LiveStore for a principled, event-sourcing based development model. Or distributed SQlite or native iOS apps.
TanStack
Great for super fast web, mobile and AI app development.
Database | Backend | Schema | Proxy | Client | Writes |
---|---|---|---|---|---|
Postgres | TanStack Start | Drizzle | Cloudflare | TanStack DB | tRPC |
Tanstack DB is a reactive client store for building super fast apps on sync.
Paired with Electric and TanStack Start, it gives you an end-to-end sync stack that's type-safe, declarative, incrementally adoptable and insanely fast.
End-to-end Typescript
See the tanstack-db-web-starter for an example of an end-to-end Typescript stack for web app development:
- based on Postgres, using Drizzle for data schemas and migrations
- syncing data out of Electric through TanStack Start server functions
- into TanStack DB collections for reactive, local-first client-side development
- using tRPC mutation proceedures for type-safe write handling on the server
See also the tanstack-db-expo-starter for a similar stack for mobile app development.
Incremental adoption
TanStack DB is designed to be incrementally adoptable into existing applications.
It's tiny — a few Kbs — so doesn't introduce a big dependency. It works with all major front-end reactivity frameworks. It works with API-based data loading and sync. So you can progressively adopt by first migrating API-based apps using TanStack Query and then migrate to sync without affecting the component code.
Super fast 🔥
When you combine Electric with TanStack DB, you get blazing fast end-to-end reactivity.
Components use live queries to react and when data changes. These are based on a Typescript implementation of differential dataflow. This means you can build complex client apps where everything reacts instantly, within a single animation frame.
More information
- Local-first sync with TanStack DB and Electric
- TanStack DB, the embedded client database for TanStack Query
- An interactive guide to TanStack DB
Phoenix
Great for agentic systems and full-stack development.
Database | Backend | Schema | Proxy | Client | Writes |
---|---|---|---|---|---|
Postgres | Phoenix | Ecto | Phoenix | TanStack DB | Phoenix |
Phoenix is a full-stack web development framework for Elixir.
Electric is developed in Elixir, has a first-class Elixir client and a deep Phoenix framework integration in the form of the official Phoenix.Sync library.
Phoenix.Sync
Phoenix.Sync enables real-time sync for Postgres-backed Phoenix applications. You can use it to sync data into Elixir, LiveView
and frontend web and mobile applications.
Using with TanStack DB
Read-path sync works naturally with TanStack DB. Plus it provides:
- a
Writer
module for ingesting TanStack DB mutations Igniter
andMix
commands to integrate TanStack DB with Phoenix
Building agentic systems
Phoenix is built in Elixir, which runs on the BEAM. The BEAM provides a robust agentic runtime environment with built-in primitives for process supervision and messaging.
This makes Elixir and Phoenix a perfect match for agentic system development without needing a seperate agent framework.
More information
- Burn agentic demo app
- Bringing agents back down to earth blog post
- Phoenix integration page
- Phoenix.Sync documentation
PGlite
Great for dev, test and sandbox environments.
Database | Client | Writes |
---|---|---|
Postgres | PGlite | Custom |
PGlite is an embeddable Postgres database.
Electric can sync data into PGlite to hydrate lightweight database instances for dev, test and sandboxed environments
Lightweight developer database
Platforms including Google Firebase, Supabase and Prisma all use PGlite as a development database. It's proper Postgres that can run embedded, in-process. So you don't need any external processes or system packages to use it.
Having a Postgres database is as simple as:
npm install @electric-sql/pglite
import { PGlite } from '@electric-sql/pglite'
const db = new PGlite()
Database in the sandbox
AI app builders like Bolt, Lovable and Replit can generate database-driven apps and run them in a sandboxed dev environment. However, to actually work, these apps need to connect to a database.
PGlite is a Postgres database that runs inside your dev environment. With it, you can one-shot database-driven apps that run without leaving the sandbox.
Hydrating PGlite
Electric can be used to hydrate data into a PGlite instance using the sync plugin:
import { electricSync } from '@electric-sql/pglite-sync'
const pg = await PGlite.create({
extensions: {
electric: electricSync(),
},
})
This supports individual tables and transactionally syncing multiple tables.
More information
- PGlite website and docs
- LinearLite demo using PGlite with Electric
- Database.build by Supabase (running on PGlite)
- Vibe coding with a database in the sandbox
Yjs
Great for fine-tuned realtime collaboration.
Database | Client | Writes |
---|---|---|
Postgres | Yjs | Yjs |
Yjs is a library for building collaborative applications.
Conflict-free updates
Electric can be used as a transport layer with Yjs to create collaborative, multi-user applications on top of Postgres.
Multi-user collaboration
This works by exposing a Shape to sync changes for a Y.Doc. The y-electric
package then automatically shares updates across all connected clients.