@sharesync/sharedb

v6.1.1

Published

JSON OT database backend

Downloads

134

Readme

ShareDB

NPM Version Test Coverage Status

ShareSync: Enhanced ShareDB with DurableStore

This is the ShareSync fork of ShareDB, which introduces a new DurableStore system for offline-first client persistence. The DurableStore allows clients to persist documents and operations using pluggable storage adapters, enabling:

  • Complete offline capability - Users can work entirely offline, with operations queued for sync upon reconnection
  • Multi-document working sets - Persist multiple documents with pending operations across browsing sessions
  • Transparent operation sync - Offline operations automatically sync to ShareDB when connectivity returns
  • Client-side persistence - Documents remain available even after closing and reopening the application
  • Multi-tab safety - ProxyConnection with MessageBroker enables safe DurableStore usage across multiple browser tabs
  • Enhanced TypeScript support - Comprehensive type definitions for DurableStore, storage adapters, and client APIs

The DurableStore system is a unique enhancement not available in the original upstream ShareDB, specifically designed for offline-first collaborative applications.

Introduction

ShareDB is a realtime database backend based on Operational Transformation (OT) of JSON documents. It is the realtime backend for the DerbyJS web application framework.

For help, questions, discussion and announcements, join the ShareJS mailing list or read the documentation.

Please report any bugs you find to the issue tracker.

Features

  • Realtime synchronization of any JSON document
  • Concurrent multi-user collaboration
  • Synchronous editing API with asynchronous eventual consistency
  • Realtime query subscriptions
  • Simple integration with any database
  • Horizontally scalable with pub/sub integration
  • Projections to select desired fields from documents and operations
  • Middleware for implementing access control and custom extensions
  • Ideal for use in browsers or on the server
  • Offline change syncing upon reconnection
  • Bulk document operations for efficient multi-document loading and writing
  • Advanced offline persistence with DurableStore and pluggable storage layers
  • Caller-controlled batch writing with auto-flush control
  • In-memory implementations of database and pub/sub for unit testing
  • Access to historic document versions
  • Realtime user presence syncing

React Native Support

For React Native applications using the DurableStore system, use the dedicated storage adapter:

This storage adapter provides DurableStore integration with:

  • Client-side document persistence using SQLite in React Native
  • Offline operation queuing and automatic sync
  • Pre-initialized database support for complex architectures
  • Dual-database integration (builtin + userdata schemas)
  • Connection pooling with dependency injection
  • Cross-database queries for analytics
  • Zero bundling conflicts with browser/Node.js apps

DurableStore Storage Architecture:

  • Browser: Built-in IndexedDB storage adapter (default)
  • React Native: SQLite storage adapter (via separate package)
  • Custom: Third-party storage adapters can be implemented for any persistence backend

Documentation

https://share.github.io/sharedb/

Examples

Counter

Leaderboard

Development

Documentation

The documentation is stored as Markdown files, but sometimes it can be useful to run these locally. The docs are served using Jekyll, and require Ruby >2.4.0 and Bundler:

gem install jekyll bundler

The docs can be built locally and served with live reload:

npm run docs:install
npm run docs:start