Introduction
Loro is a CRDT library that makes building local-first, collaborative applications practical. Written in Rust for performance, it provides rich data types (text, lists, maps, trees, counters) that merge automatically without a central server, along with built-in document history and time travel.
What Loro Does
- Provides rich CRDT containers including text with formatting (Peritext-based), lists, maps, trees, and counters
- Merges concurrent edits from multiple users automatically without conflicts
- Tracks full document history with time-travel capabilities for undo, versioning, and audit trails
- Encodes documents into compact binary snapshots for efficient storage and network transfer
- Offers first-class JavaScript/TypeScript and Rust APIs with Swift and Python bindings in progress
Architecture Overview
Loro implements a novel event graph-based CRDT architecture. Each edit is recorded as an operation in a directed acyclic graph (the event graph), which preserves causality. This design separates the merge semantics from the storage format, enabling compact encoding and fast replay. The Rust core is compiled to WebAssembly for browser use, delivering near-native performance in JavaScript environments.
Self-Hosting & Configuration
- Install via npm (
loro-crdt) for JavaScript or addloroas a Cargo dependency for Rust - No server required for basic local-first use; documents sync peer-to-peer via exported binary diffs
- For server-mediated sync, use
doc.export({ mode: "updates" })to send incremental changes - Apply remote changes with
doc.import(bytes)on any peer to merge state automatically - Persist documents as snapshots to any storage backend (file system, IndexedDB, S3)
Key Features
- Peritext-based rich text CRDT that correctly handles concurrent formatting changes
- Movable tree container for hierarchical data like outlines, file trees, and kanban boards
- Sub-document composition for modular, independently-syncable document sections
- Compact binary encoding that is significantly smaller than JSON-based CRDT formats
- Full event graph history enables branching, merging, and checkout of any past version
Comparison with Similar Tools
- Yjs — mature and widely adopted text CRDT library; Loro adds richer data types, built-in history, and a Rust core for higher throughput
- Automerge — another Rust-based CRDT with a JSON document model; Loro offers more specialized containers and different merge semantics for text
- Diamond Types — high-performance text CRDT focused on a single data type; Loro provides a full suite of composable containers
- ShareDB — OT-based real-time collaboration that requires a central server; Loro is decentralized by design
FAQ
Q: Does Loro work in the browser? A: Yes. The Rust core compiles to WebAssembly, and the npm package works in all modern browsers and Node.js.
Q: How does Loro handle conflicts in rich text? A: Loro implements the Peritext algorithm, which correctly merges concurrent bold, italic, and other formatting operations according to user intent.
Q: Do I need a server to use Loro? A: No. Loro is transport-agnostic. You can sync over WebSocket, WebRTC, HTTP, or even sneakernet via exported binary files.
Q: How large are Loro documents? A: Loro uses a compact binary format. A document with thousands of edits typically compresses to a few kilobytes, much smaller than equivalent JSON representations.