Skip to content

Dancode-188/synckit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

253 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

SyncKit

True offline-first sync for modern appsโ€”without vendor lock-in

npm version Build Status License Bundle Size TypeScript PRs Welcome

Getting Started โ€ข Documentation โ€ข Examples โ€ข Discussions โ€ข Roadmap


๐ŸŽฏ What is SyncKit?

Build collaborative apps in hours, not months.

SyncKit is a production-ready sync engine that gives you everything for local-first collaboration:

  • Rich text editing with conflict resolution (Peritext + Fugue CRDTs)
  • Undo/redo that syncs across tabs and sessions
  • Live presence and cursor sharing
  • Framework adapters for React, Vue, and Svelte

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

The reality: Building sync from scratch takes months. SyncKit gives you production-ready collaboration 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

๐ŸŽฌ See It In Action

โšก Try Live Demo โ†’

LocalWrite - Full-featured collaborative editor showcasing SyncKit's capabilities.

Quick test (30 seconds):

  1. Open localwrite-demo.fly.dev in two browser tabs
  2. Click "Join a Room" in both tabs (auto-joins same room)
  3. Type in one tab โ†’ appears instantly in the other
  4. Watch live cursors showing each user's position

What you'll see:

  • Character-level sync - No debouncing, no lag
  • Conflict-free merging - Multiple users editing simultaneously
  • Block-based editor - Slash commands (/h1, /list) with real-time formatting
  • Presence & cursors - See who's online, where they're typing
  • Offline-first - Disconnect your network, keep editing, auto-sync on reconnect
  • Word Wall - Community voting feature (bonus: shows OR-Set CRDT in action)

Real-world example:

import { SyncKit } from '@synckit-js/sdk'
import { useSyncDocument } from '@synckit-js/sdk/react'

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

// Use in components
function TaskList() {
  const [tasks, { update }] = useSyncDocument<Task[]>('tasks')

  const toggleTask = (id: string) => {
    update(tasks.map(t =>
      t.id === id ? { ...t, completed: !t.completed } : t
    ))
  }
  // Syncs across all connected clients automatically
}

โœจ Why SyncKit?

๐Ÿš€ 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.

๐Ÿ“ฆ Production-Ready, Feature-Complete

154KB gzipped - Complete local-first sync solution with everything you need.

What you get:

  • โœ… Text editing (Fugue CRDT) - Collaborative editing that just works
  • โœ… Rich text formatting (Peritext) - Bold, italic, links with conflict resolution
  • โœ… Undo/redo - Syncs across tabs, persists across sessions
  • โœ… Real-time presence - See who's online, what they're editing
  • โœ… Cursor sharing - Watch teammates type in real-time
  • โœ… Counters & Sets - Distributed data structures for app state
  • โœ… Framework adapters - React, Vue, Svelte (choose what you need)
  • โœ… Offline-first sync - Works perfectly without internet
  • โœ… IndexedDB persistence - Unlimited local storage

Size-critical apps? Use Lite variant (46KB gzipped, basic sync only)

Every byte is justified. We chose completeness over minimal sizeโ€”rich text, undo/redo, cursors, and framework adapters all work together out of the box.

๐Ÿ”“ Your Data, Your Rules

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

โšก Fast by Design

  • <1ms local operations (~5-20ฮผs single field update)
  • <100ms sync latency (10-50ms p95)
  • 154KB bundle (complete solution), 46KB lite option
  • ~310KB total with React (comparable to React alone)

๐Ÿ›ก๏ธ Data Integrity Guaranteed

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

๐Ÿš€ Quick Start

Installation

npm install @synckit-js/sdk

Your First Synced App

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 (154KB gzipped) + React (156KB) = ~310KB total

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

Full tutorial (5 minutes) โ†’


๐ŸŽ“ Features

Text Editing & Collaboration

  • โœ๏ธ Text CRDT (Fugue) - Collaborative editing with conflict-free convergence
  • ๐ŸŽจ Rich Text (Peritext) - Bold, italic, links with proper formatting merge
  • โ†ฉ๏ธ Undo/Redo - Cross-tab undo that syncs everywhere
  • ๐Ÿ‘ฅ Awareness & Presence - See who's online and what they're editing
  • ๐Ÿ–ฑ๏ธ Cursor Sharing - Real-time cursor positions with smooth animations
  • ๐Ÿ”ข Counters & Sets - Distributed counters (PN-Counter) and sets (OR-Set)

Framework Integration

  • โš›๏ธ React Hooks - Complete hook library for all features
  • ๐ŸŸข Vue Composables - Idiomatic Vue 3 Composition API integration
  • ๐Ÿ”ถ Svelte Stores - Reactive Svelte 5 stores with runes support

Core Capabilities

  • ๐Ÿ”„ 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 for documents, CRDTs for collaboration
  • โšก Fast Operations - <1ms local updates, <100ms sync latency
  • ๐Ÿ“ฆ Production Bundle - 154KB gzipped (complete) or 46KB (lite)
  • ๐Ÿ” Secure - JWT authentication, RBAC permissions

๐Ÿ—๏ธ Architecture

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/C#]

    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 โ†’


๐Ÿ“š Documentation

Getting Started

Core Concepts

Migration Guides

Examples

Browse all docs โ†’


๐ŸŽฏ Use Cases

Tier 1: Simple Object Sync (LWW)

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

import { SyncKit } from '@synckit-js/sdk'
import { useSyncDocument } from '@synckit-js/sdk/react'

// 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

Perfect for: Collaborative editors, documentation, notes

import { useSyncText } from '@synckit-js/sdk/react'

const [text, { insert, delete: del }] = useSyncText('document-456')
await insert(0, 'Hello ')
// Character-level sync, conflict-free convergence

Tier 3: Counters & Sets

Perfect for: Likes, votes, tags, participants

import { useCounter, useSet } from '@synckit-js/sdk/react'

const [count, { increment, decrement }] = useCounter('likes-789')
await increment()  // Conflict-free counter

const [tags, { add, remove }] = useSet<string>('post-tags')
await add('typescript')  // Observed-remove set

๐ŸŒ How SyncKit Fits the Ecosystem

Different libraries make different trade-offs. Here's how SyncKit compares:

Feature SyncKit Firebase Supabase Yjs Automerge
Bundle Size (gzipped) 154KB
(46KB lite)
~150โ€“200KB
(typical client)
~45KB
(JS client)
65KB
(core)
300KB+
(JS/WASM)
Text CRDT โœ… Fugue โŒ No โŒ No โœ… Y.Text โœ… Yes
Rich Text โœ… Peritext โŒ No โŒ No โš ๏ธ Limited โœ… Yes
Undo/Redo โœ… Cross-tab โŒ No โŒ No โš ๏ธ Basic โœ… Yes
Awareness/Cursors โœ… Built-in โŒ No โŒ No โš ๏ธ Extension โŒ No
Framework Adapters โœ… React/Vue/Svelte โŒ No โŒ No โš ๏ธ Community โŒ No
True Offline-First โœ… Native โš ๏ธ Limited (cache + persistence) โŒ No native support โœ… Full โœ… Full
Works Without Server โœ… Yes โŒ No โŒ No โœ… Yes โœ… Yes
Self-Hosted โœ… Yes โŒ No โœ… Yes โœ… Yes โœ… Yes
TypeScript Support โœ… Native โœ… Good โœ… Good โš ๏ธ Issues โœ… Good
Production Status โœ… v0.3.0 โœ… Mature โœ… Mature โœ… Mature โš ๏ธ Stable core,
evolving ecosystem

When to Choose SyncKit

Choose SyncKit if:

  • โœ… You need rich text, undo/redo, cursors, and framework adapters included
  • โœ… You want Vue or Svelte support (not just React)
  • โœ… You value shipping fast over optimizing every byte
  • โœ… You want true offline-first without vendor lock-in

Choose alternatives if:

  • Firebase/Supabase: You need a full backend-as-a-service (auth, storage, functions) and offline sync isn't critical
  • Yjs: Minimal bundle size is your #1 priority and you're okay wiring up separate plugins for undo, presence, and framework support.
  • Automerge: You need JSON patching or unique Automerge features (and can accept 300KB+ bundle)

See detailed migration guides โ†’


๐Ÿ“ฆ Packages

Core

  • @synckit-js/sdk - Core SDK (TypeScript) + WASM engine
  • @synckit-js/sdk/react - React hooks and components (export from SDK)
  • @synckit-js/sdk/vue - Vue 3 composables (export from SDK)
  • @synckit-js/sdk/svelte - Svelte 5 stores with runes (export from SDK)
  • @synckit-js/sdk/lite - Lightweight version (local-only, 46KB gzipped)

Servers

  • @synckit-js/server - Bun + Hono TypeScript server (production-ready)
  • Python Server - FastAPI implementation (production-ready, v0.3.0)
  • Go Server - High-performance goroutine-based server (production-ready, v0.3.0)
  • C# Server - ASP.NET Core implementation (production-ready, community-contributed)

๐Ÿšฆ Status

Current Version: v0.3.0

Production Ready โœ…

The core sync engine is battle-tested and ready for production:

  • โœ… Document Sync - LWW conflict resolution with vector clocks
  • โœ… Text CRDT (Fugue) - Collaborative text editing with conflict-free convergence
  • โœ… Rich Text (Peritext) - Bold, italic, links with formatting conflict resolution
  • โœ… Counters & Sets - PN-Counter and OR-Set CRDTs
  • โœ… Offline-First Architecture - Works perfectly without internet
  • โœ… WebSocket Protocol - Real-time server synchronization
  • โœ… Core Rust Engine - Memory-safe WASM with zero unsafe blocks
  • โœ… WASM Compilation - 154KB gzipped (46KB lite), optimized performance
  • โœ… TypeScript SDK - Document, Text, RichText, Counter, Set APIs
  • โœ… Storage Adapters - IndexedDB, Memory, and OPFS
  • โœ… Multi-Language Servers - TypeScript, Python, Go, and C# (all production-ready)
  • โœ… Undo/Redo - Cross-tab undo with persistent history
  • โœ… Awareness & Presence - Real-time user tracking with cursor sharing
  • โœ… Cross-Tab Sync - BroadcastChannel-based synchronization
  • โœ… Framework Adapters - React hooks, Vue 3 composables, Svelte 5 stores
  • โœ… Quill Integration - QuillBinding for Quill editor
  • โœ… Snapshot API - Document snapshots with automatic scheduling
  • โœ… Benchmark Suite - Cross-server performance comparison
  • โœ… 2,100+ Tests - 100% pass rate across TypeScript, Rust, Python, Go, and C#
  • โœ… Example Applications - Todo app, collaborative editor, project management

What's Next ๐Ÿšง

  • ๐Ÿšง Rust Server - Native Rust server implementation
  • ๐Ÿšง SQLite Storage - For Node.js, Bun, and Electron
  • ๐Ÿšง SQL Sync - Multi-table relational sync
  • ๐Ÿšง Conflict UI - Visual conflict resolution interface

Full roadmap โ†’


๐Ÿค Contributing

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 Rust server
  • ๐Ÿ’ก Features - Propose new features in discussions

Contributing guide โ†’


๐Ÿข Enterprise

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: danbitengo@gmail.com


๐Ÿ“Š Benchmarks

Bundle Size (gzipped)

SyncKit (lite):      46 KB โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ
Yjs (assembled):     65 KB โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ
SyncKit (default):  154 KB โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ
Firebase:           150 KB โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ
Automerge:          300 KB โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ

Sync Performance

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 โ†’


๐Ÿ™ Acknowledgments

Research & Algorithms

SyncKit's core algorithms are based on published research:

Inspiration & Community

Built with inspiration from:

  • Loro - Production Fugue+Peritext implementation that influenced our Rust architecture
  • Yjs - Text CRDT concepts and performance optimization
  • Automerge - CRDT theory and formal verification
  • Linear - Pragmatic approach to sync
  • Figma - Custom sync architecture patterns
  • RxDB - Local-first database patterns
  • Ink & Switch - Research lab pioneering local-first software

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


๐Ÿ“„ License

MIT License - see LICENSE for details.

Copyright (c) 2025 Daniel Bitengo


๐Ÿ”— Links


Built with โค๏ธ for the local-first future

โญ Star us on GitHub โ€ข ๐Ÿ“– Read the docs โ€ข ๐Ÿš€ Get started

About

๐Ÿš€ Local-first collaboration SDK for React, Vue, and Svelte. Batteries-included: Rich text, undo/redo, cursors, and presence.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors