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.
No proprietary servers or cloud lock-in. Transparent SQLite triggers journal mutations directly inside your local database file.
Mutations hit local SQLite immediately in WAL mode. Your frontend never shows network spinners or waits for server round-trips.
SQLite AFTER INSERT/UPDATE/DELETE triggers capture deltas into _sync_changes. A session-level suppression flag prevents echo loops.
Deterministic Last-Write-Wins with microsecond timestamps. Deleted records are tracked in _sync_tombstones so stale packets cannot resurrect them.
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();
// src-tauri/src/main.rs
fn main() {
tauri::Builder::default()
// Zero-boilerplate plugin initialization
.plugin(tauri_plugin_sync::init())
.run(tauri::generate_context!())
.expect("error running tauri application");
}
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) |
Detailed technical article covering SQLite triggers, WAL mode concurrency, Last-Write-Wins microsecond resolution, and recursion suppression.