Show HN: Synclar – Offline-First SQL Sync with TypeScript and Rust Cores

Every developer who has built an app for flaky networks knows the pain: you add offline support, and suddenly you're wrestling with conflict resolution, sync ordering, and data loss. Offline-first is easy in theory but hard in practice. That's why the Show HN launch of Synclar caught my eye this week. Synclar is a new open-source tool that brings offline-first synchronization to SQL databases with two cores: a TypeScript core for ergonomic integration with JavaScript projects, and a Rust core for performance-critical operations. In this article, I'll break down the architecture, compare it with existing solutions, and give you a practical path to adopting Synclar in your next app.

Most web and mobile apps rely on a central server and a client-side cache. When the network drops, the cache becomes stale. Offline-first design flips this: the client is the source of truth and syncs changes back to the server. This requires a robust sync engine. For SQL, this is even harder because you have to reconcile table rows, primary keys, and transactions.

Why Offline-First SQL Sync Is Hard

When you let multiple clients modify the same SQL table offline, you inevitably face conflicts. Classic strategies like last-write-wins (LWW) can silently lose data. More sophisticated approaches use Operational Transformation (OT) or Conflict-free Replicated Data Types (CRDTs). CRDTs guarantee eventual consistency without a central coordinator, but they require data structures that fit the data model. For SQL, this is tricky. You have foreign keys, unique constraints, and multi-row transactions.

Additionally, the sync layer must handle partial failures, idempotency, and schema migrations. The CAP theorem says you cannot have consistency, availability, and partition tolerance simultaneously. Offline-first favors availability and partition tolerance, but you must choose a consistency model. Most tools lean toward eventual consistency, where the server resolves conflicts deterministically.

Meet Synclar: Two Cores, One Mission

Synclar takes a pragmatic approach. Instead of trying to be a full database, it acts as a sync layer on top of SQLite. The TypeScript core provides a familiar API for web developers, allowing you to define tables, triggers, and sync policies in pure TypeScript. The Rust core handles the heavy lifting: serialization, delta compression, and checksum validation. This means you get the developer speed of TypeScript and the raw performance of Rust, without needing to write a single line of low-level code.

Having two cores is a clever design. Rust is known for memory safety and speed, making it ideal for parsing SQL binary logs and calculating diffs. TypeScript, on the other hand, is the lingua franca of the JavaScript ecosystem. Synclar can ship a WebAssembly build of the Rust core for browsers, while Node.js and mobile platforms can use the native Rust binary. This versatility is what sets it apart from single-language tools.

Architecture Overview

Synclar follows a standard offline-first architecture. Your app has a local SQLite database. Every write is recorded in a change log. The sync engine reads that log and pushes it to a remote server. Incoming changes are applied transactionally. The Rust core accelerates these operations by using a custom binary protocol for efficient data transfer.

Here’s an illustrative example of how you might configure Synclar in a TypeScript project:

import { Synclar } from 'synclar';
import { SQLiteDatabase } from 'synclar/sqlite';

const client = new Synclar({
  db: new SQLiteDatabase('app.db'),
  server: 'wss://api.example.com/sync',
  core: 'rust',          // or 'ts'
  tables: ['users', 'orders'],
  conflictResolution: 'lww',
});

client.on('sync', (result) => console.log('Sync:', result));
client.start();

This example assumes a simple global sync. In reality, you may use per-table policies, user-scoped sync, or delta sync based on timestamps. The key is that Synclar abstracts away the complexity of the sync protocol. You define the shape of your data, and the engine handles the rest.

Synclar vs. Other Tools

There are several offline-first libraries, but they target different backends. Here’s a quick comparison:

Tool Architecture Core Language Conflict Resolution Offline Support
PowerSync SQL sync for Postgres JS LWW or CRDT Yes
RxDB NoSQL (PouchDB) JS CRDT Yes
WatermelonDB SQLite JS LWW Yes
Synclar SQLite sync TypeScript + Rust LWW (configurable) Yes

While PowerSync is excellent for Postgres and RxDB is great for NoSQL, Synclar focuses on SQLite-style local databases. It positions itself as a lighter-weight alternative for small to medium apps, especially when you need the performance of Rust for processing large change sets. The dual-core strategy is unique — no other tool offers a native TS + Rust split.

Getting Started with Synclar: Practical Tips

If you're excited to try Synclar, here are a few tips:

  1. Start with SQLite — It’s the most battle-tested local database. Synclar's Rust core likely optimizes SQLite-specific operations, so you'll get the best performance.
  2. Design your sync schema carefully — Use monotonic timestamps or UUIDs for primary keys to avoid conflicts. Sync engines work best when every row has a stable identifier.
  3. Test with throttled network — Chrome DevTools has a network throttle. Simulate poor connectivity to ensure your app handles retries and backoff gracefully.
  4. Use the Rust core for mobile — On iOS/Android, the Rust native binary outperforms WebAssembly. For web, the WASM build is fine, but expect higher memory usage.

When you need to connect the server side of Synclar to other cloud services or APIs, you'll likely build a custom REST or GraphQL endpoint. If you want to master these integration patterns, ASI Biont offers practical courses on API integrations — see asibiont.com/courses.

Conclusion

Synclar is a promising addition to the offline-first ecosystem. By combining the ergonomics of TypeScript with the performance of Rust, it tackles a real pain point: SQL sync that works offline without sacrificing speed. Whether you're building a chat app, a field service tool, or a collaborative editor, Synclar’s dual-core approach could save you months of work.

Of course, the project is young — always check the latest docs and source code before committing to production. But the architectural ideas it brings are fresh and worth studying. If you've been avoiding offline-first because of the complexity, Synclar might just be the kick in the right direction.

← All posts

Comments