TS
tauri-plugin-sync v0.1.2
Tauri v2 · SQLite CDC · 15/15 Passing

Offline-first SQLite sync for Tauri desktop apps.

A lightweight Tauri v2 plugin that captures SQLite mutations with transparent CDC triggers, replicates them asynchronously via Tokio, and converges deterministically using microsecond Last-Write-Wins.

$ npm i tauri-plugin-sync
View on GitHub
tauri-sync-showcase-1080p.mp4
Median Latency: 0.13ms (p50)
CDC Overhead: < 0.09ms
Stress Convergence: 1,000 Ops / 1.02s
CI Test Matrix: 15 / 15 Passed
Architecture

How it works under the hood

No proprietary servers or cloud lock-in. Transparent SQLite triggers journal mutations directly inside your local database file.

01 / LOCAL WRITES

Direct SQLite WAL Execution

Mutations hit local SQLite immediately in WAL mode. Your frontend never shows network spinners or waits for server round-trips.

median_latency = 0.13ms (p50) / 0.34ms mean
02 / CDC TRIGGERS

Recursion-Proof Capture

SQLite AFTER INSERT/UPDATE/DELETE triggers capture deltas into _sync_changes. A session-level suppression flag prevents echo loops.

guard: suppressed = 0
03 / CONVERGENCE

Microsecond LWW & Tombstones

Deterministic Last-Write-Wins with microsecond timestamps. Deleted records are tracked in _sync_tombstones so stale packets cannot resurrect them.

rule: deleted_at >= remote_ts
Quickstart

Drop into your Tauri v2 app

Register the plugin in Rust and initialize the TypeScript SDK on the frontend.

import { SyncManager } from 'tauri-plugin-sync';

// 1. Initialize Sync with your local SQLite database
const sync = await SyncManager.init({
  database: 'app.db',
  endpoint: 'https://api.example.com/sync',
  tables: ['todos', 'notes'],
  authHeader: 'Bearer eyJhbGci...',
  syncIntervalMs: 5000, // background polling interval
  batchSize: 500,       // max changes per batch
});

// 2. Reactive sync status ('idle' | 'syncing' | 'offline' | 'error')
sync.onStatusChange(({ state }) => {
  console.log('Sync status:', state);
});

// 3. Local writes are automatically captured by SQLite triggers
await sync.syncNow();
Technical Credibility

Verified & Reproducible Benchmarks

Run the benchmark harness locally: cargo run --example benchmark --release

Operation Target Measured Latency Notes
Direct Local Write todos (1 row) 0.13 ms (p50) / 0.34 ms (Mean) WAL mode commit
CDC Trigger Execution _sync_changes journal < 0.09 ms json_object() serialization
Stress Convergence 1,000 concurrent ops 1.02 s Dual-client divergence
CI Test Suite 15 unit, edge-case & integration tests 1.27 s GitHub Actions (Ubuntu/macOS/Win)
Architecture Deep Dive

Building an Offline-First SQLite Sync Engine for Tauri v2

Detailed technical article covering SQLite triggers, WAL mode concurrency, Last-Write-Wins microsecond resolution, and recursion suppression.

Read Article →