Show HN: SyncKit – 离线优先同步引擎 (Rust/WASM 和 TypeScript)
Show HN: SyncKit – Offline-first sync engine (Rust/WASM and TypeScript)

原始链接: https://github.com/Dancode-188/synckit

## SyncKit:轻松实现本地优先同步 SyncKit是一个生产就绪的同步引擎,旨在简化构建本地优先应用程序,消除从头开始构建同步的复杂性。与缺乏可靠离线支持的Firebase和Supabase等现有解决方案,或像Yjs和Automerge这样复杂的选项不同,SyncKit只需三行代码即可提供具有离线弹性的实时协作。 它具有较小的占用空间(gzip压缩后约59KB,其中“lite”版本约45KB),利用基于WASM的引擎实现性能和多语言服务器支持,并以自动冲突解决(最后写入者胜出)和形式化验证保证数据完整性。 目前版本为v0.1.0,SyncKit提供离线优先同步、跨标签页同步和IndexedDB持久化。未来版本(v0.2.0)将引入文本CRDT和分布式计数器/集合。它开源、可自托管,并提供比替代方案更简单的API,使其成为各种应用程序的理想选择——从任务管理到协作编辑器。

## SyncKit:一种新型离线优先同步引擎 开发者 danbitengo 发布了 SyncKit,一种旨在简化本地优先应用程序跨设备同步的新型同步引擎。由于对现有解决方案(如 Automerge/Yjs)的复杂性以及基于云的选项(如 Firebase 和 Supabase)的局限性感到沮丧,SyncKit 旨在实现简单性和功能的平衡。 SyncKit 使用 Rust 和 WASM 构建(压缩后 48.9KB),优先考虑可靠性,拥有超过 700 个测试——包括混沌测试——并利用 TLA+ 形式化验证主动识别错误。它目前支持后写入胜出 (LWW) 冲突解决,并提供使用 Bun/Hono WebSockets 构建的服务器。 目前处于 v0.1.0 版本,SyncKit 专注于 React 集成,未来计划支持 Vue、Svelte,以及可能支持 React Native。该项目是开源的,可在 GitHub 上找到 ([https://github.com/Dancode-188/synckit](https://github.com/Dancode-188/synckit))。
相关文章

原文

SyncKit is a production-ready sync engine that makes building local-first applications trivial.

"Add sync.document() to your app, get real-time sync automatically."

The problem: Building sync from scratch takes months. Existing solutions are complex (Yjs), expensive (Firebase), or don't work offline (Supabase).

The solution: SyncKit gives you production-ready sync in 3 lines of code.

const sync = new SyncKit()
await sync.init()
const doc = sync.document<Todo>('todo-123')
await doc.update({ completed: true })
// ✨ Works offline, syncs automatically, resolves conflicts

SyncKit Demo

Real-time collaboration with offline resilience: Watch tasks sync instantly across tabs—even while offline. The example app demonstrates SyncKit's offline-first capabilities combined with smart browser storage to create a seamless collaborative experience.


🚀 Works When Internet Doesn't

True offline-first architecture—not just caching. Your app works perfectly on planes, trains, tunnels, and coffee shops with spotty WiFi.

📦 Enterprise Features, Startup Bundle

~59 KB gzipped (10KB SDK + 49KB WASM) - Complete WASM-based sync engine with TypeScript SDK.

Current features (v0.1.0):

  • ✅ Offline-first sync (LWW)
  • ✅ Real-time collaboration
  • ✅ Network protocol support
  • ✅ IndexedDB persistence
  • ✅ Cross-tab sync (see example)

Coming in v0.2.0:

  • 🚧 Text CRDTs (character-level editing)
  • 🚧 Counters, Sets (distributed data structures)

Size-critical apps? Use Lite variant (~45 KB gzipped: 1.5KB SDK + 44KB WASM, local-only)

Competitive bundle size: Larger than Yjs (~19KB pure JS), smaller than Automerge (~60-78KB).

🔓 Your Data, Your Rules

Open source and self-hostable. No vendor lock-in, no surprise $2,000/month bills, complete data sovereignty.

  • <1ms local operations (~5-20μs single field update)
  • <100ms sync latency (10-50ms p95)
  • ~59KB bundle (10KB SDK + 49KB WASM), ~45KB lite option
  • Sub-200KB total with React

🛡️ Data Integrity Guaranteed

  • Zero data loss with automatic conflict resolution (Last-Write-Wins)
  • Formal verification with TLA+ (3 bugs found and fixed)
  • 700+ comprehensive tests across TypeScript and Rust (unit, integration, chaos, load)

Feature SyncKit Firebase Supabase Yjs Automerge
True Offline-First ✅ Native ⚠️ Cache only
(40MB limit)
❌ None
(#357 - 4+ years)
✅ Full ✅ Full
Works Without Server ✅ Yes ❌ No ❌ No ✅ Yes ✅ Yes
Bundle Size (gzipped) ~59KB
(45KB lite)
~150KB ~45KB ~19KB ~60-78KB
Text CRDT 🚧 v0.2.0 ❌ No ❌ No ✅ Yes ✅ Yes
Counters/Sets 🚧 v0.2.0 ❌ No ❌ No ✅ Yes ✅ Yes
Automatic Conflicts ✅ LWW ✅ LWW ⚠️ Manual ✅ CRDT ✅ CRDT
Self-Hosted ✅ Yes ❌ No ✅ Yes ✅ Yes ✅ Yes
Multi-Language Server ✅ TS
🚧 Py/Go/Rust
❌ No ⚠️ Postgres only ❌ JS only ❌ JS only
Pricing Free (self-host) $25-$2,000+/mo $0-$25/mo Free Free
TypeScript Support ✅ Native ✅ Good ✅ Good ⚠️ Issues ✅ Good
Learning Curve ✅ 5 minutes ⚠️ Medium ⚠️ Medium ⚠️ Steep ⚠️ Complex
Production Status ✅ v0.1.0 ready ✅ Mature ✅ Mature ✅ Mature ⚠️ Alpha/Beta

TL;DR:

  • vs Firebase: No vendor lock-in, true offline, predictable costs
  • vs Supabase: Actually works offline (their #1 issue for 4+ years)
  • vs Yjs: WASM-based for multi-language server support, simpler API for structured data
  • vs Automerge: Smaller bundle, faster performance, production-ready

See detailed migration guides →


npm install @synckit-js/sdk
import { SyncKit } from '@synckit-js/sdk'
import { SyncProvider, useSyncDocument } from '@synckit-js/sdk/react'

// Initialize (works offline-only, no server needed!)
const sync = new SyncKit()
await sync.init()

function App() {
  return (
    <SyncProvider synckit={sync}>
      <TodoApp />
    </SyncProvider>
  )
}

function TodoApp() {
  const [todo, { update }] = useSyncDocument<Todo>('todo-1')

  if (!todo || !todo.text) return <div>Loading...</div>

  return (
    <div>
      <input
        type="checkbox"
        checked={todo.completed}
        onChange={(e) => update({ completed: e.target.checked })}
      />
      <span>{todo.text}</span>
    </div>
  )
}

That's it! Your app now:

  • ✅ Works 100% offline
  • ✅ Syncs across tabs automatically
  • ✅ Persists data in IndexedDB
  • ✅ Resolves conflicts automatically

Bundle: SyncKit (~59 KB gzipped) + React (~130 KB) = ~189 KB total

Size-critical? import { SyncKit } from '@synckit-js/sdk/lite' (~45 KB gzipped, local-only)

Full tutorial (5 minutes) →


  • 🔄 Real-Time Sync - WebSocket-based instant sync across devices
  • 📴 Offline-First - Works perfectly with zero connectivity
  • 🗄️ Local Persistence - IndexedDB storage, unlimited capacity
  • 🔀 Conflict Resolution - Automatic Last-Write-Wins (LWW) merge
  • ⚡ Fast Operations - <1ms local updates, <100ms sync latency
  • 📦 Compact Bundle - ~59KB gzipped (10KB SDK + 49KB WASM)
  • 🔐 Secure - JWT authentication, RBAC permissions
  • ⚛️ React Hooks - useSyncDocument, useSyncField, SyncProvider
  • 🌐 TypeScript Server - Bun + Hono reference implementation
  • 📦 Multi-Variant - Default (~59KB gzipped) or Lite (~45KB gzipped) builds
  • ✍️ Text CRDTs - Collaborative text editing (character-level sync)
  • 🔢 Counters - Conflict-free increment/decrement
  • 📋 Sets & Lists - Observed-Remove Sets for collections
  • 🎨 Framework Adapters - Vue composables, Svelte stores
  • 🌐 Multi-Language Servers - Python, Go, Rust implementations

graph TD
    A[Your Application<br/>React/Vue/Svelte] --> B[SyncKit SDK<br/>TypeScript]

    B -->|Simple API| B1[document, text, counter]
    B -->|Framework adapters| B2[React/Vue/Svelte hooks]
    B -->|Offline queue| B3[Storage adapters]

    B --> C[Rust Core Engine<br/>WASM + Native]

    C -->|80% of use cases| C1[LWW Sync]
    C -->|Collaborative editing| C2[Text CRDTs]
    C -->|Advanced features| C3[Custom CRDTs<br/>counters, sets]

    C --> D[IndexedDB Storage<br/>Your local source of truth]

    D -.->|Optional| E[SyncKit Server<br/>TypeScript/Python/Go/Rust]

    E -->|Real-time sync| E1[WebSocket]
    E -->|Persistence| E2[PostgreSQL/MongoDB]
    E -->|Security| E3[JWT auth + RBAC]

    style A fill:#e1f5ff,stroke:#333,stroke-width:2px,color:#1a1a1a
    style B fill:#fff4e1,stroke:#333,stroke-width:2px,color:#1a1a1a
    style C fill:#ffe1e1,stroke:#333,stroke-width:2px,color:#1a1a1a
    style D fill:#e1ffe1,stroke:#333,stroke-width:2px,color:#1a1a1a
    style E fill:#f0e1ff,stroke:#333,stroke-width:2px,color:#1a1a1a
Loading

Detailed architecture docs →


Browse all docs →


Tier 1: Simple Object Sync (LWW)

Perfect for: Task apps, CRMs, project management, note apps (80% of applications)

// Initialize once
const sync = new SyncKit()
await sync.init()

// Use anywhere
const doc = sync.document<Project>('project-123')
await doc.update({ status: 'completed' })
// Conflicts resolved automatically with Last-Write-Wins

Tier 2: Collaborative Text Editing (Coming Soon)

Perfect for: Collaborative editors, documentation, notes

// Note: Text CRDT API is planned for v0.2.0
const text = sync.text('document-456')
await text.insert(0, 'Hello ')
text.subscribe(content => editor.setValue(content))
// Character-level sync, conflict-free convergence

Tier 3: Custom CRDTs (Coming Soon)

Perfect for: Whiteboards, design tools, specialized apps

// Note: Counter API is planned for v0.2.0
const counter = sync.counter('likes-789')
await counter.increment()
// Conflict-free counter (additions never conflict)

  • @synckit-js/sdk - Core SDK (TypeScript) + WASM engine
  • @synckit-js/sdk/react - React hooks and components (export from SDK)
  • @synckit-js/sdk/lite - Lightweight version (local-only, 45KB gzipped)
  • @synckit-js/server - Bun + Hono reference server (production-ready)

Current Version: v0.1.0 Production Ready: Core sync engine, React hooks, TypeScript server ✅

  • Core Rust Engine - LWW sync engine with CRDT foundation
  • WASM Compilation - 59KB gzipped (45KB lite), optimized performance
  • TypeScript SDK - Document API, IndexedDB storage, offline queue
  • Cross-Tab Sync - Server-mediated sync with operation buffering for multi-tab coordination
  • React Integration - useSyncDocument, useSyncField, SyncProvider hooks
  • TypeScript Server - WebSocket sync server with Bun + Hono
  • Example Applications - Todo app, collaborative editor, project management demos
  • Documentation - Comprehensive guides and API reference
  • Build System - Complete toolchain with benchmarks and CI
  • 🚧 Text CRDTs - Collaborative text editing (useText hook) for character-level sync
  • 🚧 Counter CRDTs - Distributed counters (useCounter hook) for conflict-free increments
  • 🚧 BroadcastChannel Cross-Tab - Direct client-to-client sync without server (offline multi-tab)
  • 🚧 Framework Adapters - Vue composables (@synckit-js/sdk/vue), Svelte stores (@synckit-js/sdk/svelte)
  • 🚧 Multi-Language Servers - Python, Go, Rust server implementations (TypeScript complete)
  • 🚧 Advanced Storage - OPFS (Origin Private File System), SQLite adapter
  • 🚧 Conflict UI - Visual conflict resolution interface for complex merge scenarios

Full roadmap →


We welcome contributions from the community!

Ways to contribute:

  • 🐛 Bug Reports - Open an issue
  • 📚 Documentation - Improve guides, fix typos
  • 🧪 Tests - Add test coverage
  • 🌐 Servers - Implement Python/Go/Rust servers
  • 💡 Features - Propose new features in discussions

Contributing guide →


Need enterprise support?

  • 🎯 Managed Hosting - We host SyncKit servers for you
  • 🔒 Priority Support - 24/7 support, SLA guarantees
  • 📊 Monitoring & Analytics - Dashboard, alerts, insights
  • 🎓 Training & Consulting - Onboarding, architecture review

Contact: [email protected]


Yjs:                ~19 KB ████
SyncKit (lite):     ~45 KB █████████
SyncKit (default):  ~59 KB ████████████
Automerge:       ~60-78 KB ████████████████
Firebase:          ~150 KB ████████████████████████████████
Local update:       <1 ms  ████
Cross-tab sync:     <1 ms  ████
Network sync:    10-50 ms  ████████
Firebase (cold):  2-30 s   ████████████████████████████████

Memory Usage (10K documents)

SyncKit:       3 MB  ████
Yjs:           8 MB  █████████
Automerge:   180 MB  ████████████████████████████████████████

Detailed benchmarks →


Built with inspiration from:

  • Yjs - YATA algorithm and performance optimization
  • Automerge - CRDT theory and formal verification
  • Linear - Pragmatic approach to sync
  • Figma - Custom sync architecture patterns
  • RxDB - Local-first database patterns

Special thanks to the local-first community for pioneering this movement.


MIT License - see LICENSE for details.

Copyright (c) 2025 Daniel Bitengo



联系我们 contact @ memedata.com