DEV Community

Alex Spinov
Alex Spinov

Posted on

Electric SQL Has a Free API That Most Developers Dont Know About

Electric SQL syncs Postgres with local SQLite for local-first apps with real-time sync.

Sync + Local Queries

const electric = await electrify(db, schema, { url: "https://electric.example.com" });

// Sync specific data
await electric.db.posts.sync({ where: { status: "published" } });

// Instant local reads
const posts = await electric.db.posts.findMany({ orderBy: { createdAt: "desc" } });

// Instant local writes (synced in background)
await electric.db.posts.create({ data: { title: "Hello", authorId: userId } });
Enter fullscreen mode Exit fullscreen mode

React

const { results } = useLiveQuery(electric.db.posts.liveMany());
Enter fullscreen mode Exit fullscreen mode

Key Features

  • Local-first with Postgres sync
  • Instant reads/writes
  • Conflict-free replication
  • Works offline
  • React live queries

Need to scrape or monitor web data at scale? Check out my web scraping actors on Apify or email spinov001@gmail.com for custom solutions.

Top comments (0)