Cross-platform CRDT database built on Automerge. Runs in browsers via WebAssembly and as a native Rust sync server.
⚠️ UNDER ACTIVE DEVELOPMENT⚠️ SwirlDB is in early development and not ready for production use. The API is unstable and subject to breaking changes.
- CRDT-based: Built on Automerge for automatic conflict resolution
- Cross-platform: Browser WASM (~489KB gzipped) and native Rust server with different optimizations
- Pluggable storage: In-memory, LocalStorage, IndexedDB, or redb
- Real-time sync: WebSocket-based synchronization server
- Observable: Field-level change tracking via observers
- Policy engine: Access control for subscriptions
- Browser: WebAssembly module with JavaScript bindings
- Server: Native Rust binary for WebSocket/HTTP sync
- swirldb-core: Platform-agnostic CRDT engine and storage traits
- swirldb-browser: WASM bindings with localStorage and IndexedDB adapters
- swirldb-server: Sync server with redb storage and subscription management
See BUILD.md for build instructions.
- Rust - Install from rustup.rs
- pnpm - Install with
npm install -g pnpmorbrew install pnpm
1. Build the WASM package:
# From repository root
pnpm run build:wasm2. Use in your application:
import { SwirlDB } from '@swirldb/js';
// Configure with LocalStorage adapter (data persists automatically)
const db = await SwirlDB.withLocalStorage('my-app');
// Use natural property access via Proxies
db.data.user.name = 'Alice';
db.data.user.age = 30;
// Read values
console.log(db.data.user.name.$value); // 'Alice'
// Observe changes reactively
db.data.user.name.$observe((newValue) => {
console.log('Name changed:', newValue);
});
// Data is automatically persisted to localStorage
// No manual save/load needed!Or with in-memory storage:
// Volatile storage (nothing persists)
const db = await SwirlDB.create();Build Browser WASM:
cd native/swirldb-browser
wasm-pack build --target web --out-dir pkgBuild Server:
cd native/swirldb-server
cargo build --releasePrerequisites for Integration Tests:
# Install Node.js dependencies for browser tests
cd tests/integration
npm install
# Install Playwright for headless browser testing
npx playwright install chromiumRun All Integration Tests:
cd tests
cargo test --test integrationRun Specific Test Suites:
# Browser WebAssembly ↔ Server sync tests
cargo test --test integration browser_sync
# Subscription filtering tests
cargo test --test integration subscription_filtering
# Multi-client sync tests
cargo test --test integration multi_client_sync
# Network resilience tests
cargo test --test integration network_resilienceRun a Single Test:
cargo test --test integration test_browser_to_server_sync -- --nocaptureThe integration test suite includes:
- 32 passing tests covering Browser WASM and Rust native clients
- Real headless browser testing with Playwright
- Cross-platform CRDT synchronization validation
- Subscription filtering and policy enforcement
- Network disconnect/reconnect scenarios
See BUILD.md for detailed build instructions.
SwirlDB is built entirely from swappable adapters:
Implemented:
- ✅ In-memory (volatile, fast)
- ✅ LocalStorage (browser, 5-10MB)
- ✅ IndexedDB (browser, 50MB-1GB)
- ✅ redb (server, embedded, persistent)
- ✅ Memory adapter (server, multi-threaded)
Planned:
- 🔜 SQLite (portable, queryable)
- 🔜 Sharded files (large datasets)
- 🔜 S3 (cloud-native)
Implemented:
- ✅ WebSocket (real-time, bi-directional)
- ✅ HTTP long-polling (fallback)
Planned:
- 🔜 WebRTC (peer-to-peer)
- 🔜 Custom protocols
Planned:
- 🔜 JWT validation
- 🔜 OAuth integration
- 🔜 ABAC (attribute-based access control)
- 🔜 Custom policy engines
Planned:
- 🔜 AES-GCM (document-level)
- 🔜 Field-level encryption
- 🔜 Custom crypto implementations
Apache 2.0
Copyright 2025 Everyside Innovations, LLC