DEV Community

Alex Spinov
Alex Spinov

Posted on

Electric SQL Has Free Local-First Sync — Build Offline-First Apps with Postgres and SQLite

Why Electric SQL?

Electric SQL syncs Postgres to local SQLite databases. Your app works offline, syncs when reconnected — no conflict resolution code needed.

How It Works

  1. Your Postgres database is the source of truth
  2. Electric syncs subsets of data to client-side SQLite
  3. Users read/write to local SQLite (instant, offline-capable)
  4. Electric handles sync, conflict resolution, consistency

Quick Start

import { electrify } from 'electric-sql/wa-sqlite'
import { schema } from './generated/client'

const electric = await electrify(db, schema, config)

// Subscribe to data shape
await electric.db.items.sync({ where: { project_id: myProjectId } })

// Read (from local SQLite — instant)
const items = await electric.db.items.findMany()

// Write (to local SQLite — instant, syncs later)
await electric.db.items.create({ data: { title: 'New Item', done: false } })
Enter fullscreen mode Exit fullscreen mode

Why Local-First?

  • Instant: Reads/writes hit local SQLite, not network
  • Offline: App works without internet
  • Multiplayer: Changes sync to all clients
  • Resilient: No loading states, no network errors

Local-First vs Traditional

Aspect Local-First Client-Server
Latency 0ms (local) 50-500ms
Offline Full None
Sync Automatic Manual
Conflicts CRDT-based Manual

Need to extract data from any website at scale? I build custom web scrapers — 77 production scrapers running on Apify Store. Email me at spinov001@gmail.com for a tailored solution.

Top comments (0)