Registry / database / share
library0.5.4jsnpmunverified

ShareJS is a server and client library designed for real-time, concurrent document editing using operational transformation (OT). It supports OT on plain-text and arbitrary JSON data, allowing multiple users to collaborate on content simultaneously. The server component runs on Node.js, while the client library functions in both Node.js and web browsers, aiming for broad browser compatibility. It depends on LiveDB for its database backend and data model, and explicitly requires developers to provide a communication transport layer that guarantees in-order message delivery, warning against common pitfalls like using Socket.IO without careful configuration. The current stable version mentioned is 0.7.40. Key differentiators include its transport-agnostic design and its focus on raw OT primitives, leaving UI implementation to the developer. The project appears to be unmaintained as of early 2026, with no recent activity on its GitHub repository since around 2017.

npm install share
INSTALL
IMPORT
SIG · SHARE
S
share
databasejavascriptv0.5.4
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

livedb
var livedb = require('livedb');
import livedb from 'livedb';
ShareJS and its dependencies are primarily CommonJS modules. ESM 'import' syntax is not supported in this version.
share
var share = require('share');
import share from 'share';
The main ShareJS library is imported via CommonJS 'require'. The 'share' object itself provides access to the server and other utilities.
createClient
var shareServer = require('share').server.createClient({backend: backend});
var shareServer = require('share').createClient({backend: backend});
The server instance factory method `createClient` is nested under the `server` property of the main `share` export.

This quickstart initializes a ShareJS server with an in-memory LiveDB backend and sets up a WebSocket server to handle client connections, demonstrating the basic server-side setup.

const livedb = require('livedb'); const share = require('share'); const http = require('http'); const express = require('express'); const WebSocket = require('ws'); // 1. Initialize LiveDB backend (in-memory for simple example) const backend = livedb.client(livedb.memory()); // 2. Create ShareJS server instance const shareServer = share.server.createClient({backend: backend}); // 3. Set up HTTP server for serving client-side code (optional, but common) const app = express(); app.use(express.static(__dirname + '/public')); // Serve static files const httpServer = http.createServer(app); const wss = new WebSocket.Server({ server: httpServer }); // 4. Handle WebSocket connections for ShareJS clients wss.on('connection', (ws) => { const stream = WebSocket.createWebSocketStream(ws); shareServer.listen(stream); console.log('New ShareJS client connected via WebSocket.'); }); const PORT = process.env.PORT || 8000; httpServer.listen(PORT, () => { console.log(`ShareJS server listening on http://localhost:${PORT}`); console.log('You will need a client-side implementation to connect.'); });
Debug
Known issues
breakingThe ShareJS project, including its core repository (share/ShareJS), appears to be abandoned. The last significant commit was around 2017. Users should be aware that there will likely be no further bug fixes, security patches, or feature development. Consider alternative, actively maintained operational transformation libraries.
fix
Evaluate actively maintained alternatives like Yjs, Automerge, or other collaborative editing frameworks. If continuing with ShareJS, be prepared to fork and maintain the codebase yourself.
affects: >=0.7.40
gotchaShareJS requires a communication transport that guarantees in-order message delivery. Using libraries like `socket.io` directly without specific configuration can lead to messages arriving out of order, causing data corruption or synchronization issues.
fix
Utilize transports known to guarantee message order, such as `node-browserchannel`, or carefully configure your chosen WebSocket library (e.g., `ws`) to ensure strict ordering. Do not rely on `socket.io`'s default behavior for ShareJS communication without thoroughly understanding its ordering guarantees.
affects: >=0.6.0
gotchaThe server-side API method to create a ShareJS instance is named `createClient`, which can be confusing as it creates a 'server' object that acts as a client to the LiveDB backend. This naming choice is explicit in the documentation but often leads to initial confusion.
fix
Remember that `require('share').server.createClient()` is the correct way to instantiate the ShareJS server component. The 'client' in the name refers to its interaction with the underlying LiveDB database.
affects: >=0.6.0
gotchaDocumentation for the REST API and middleware (`share.use`) is partially external or incomplete within the main ShareJS repository. Users may need to consult separate repositories (`share/rest`, `share/middleware`) for full details, which might also suffer from the overall lack of maintenance.
fix
Refer to the linked repositories on GitHub for the most current (though potentially outdated) documentation for `share.rest()` and `share.use()`. Be prepared to examine the source code for undocumented behaviors.
affects: >=0.6.0
Errors
Common errors & fixes
Error: Cannot find module 'share'
The 'share' package has not been installed or is not resolvable in the current environment.
fix
Run `npm install share` in your project directory to install the package.
Error: Cannot find module 'livedb'
The 'livedb' package, a mandatory dependency for ShareJS, has not been installed.
fix
Run `npm install livedb` in your project directory. Depending on your chosen storage, you might also need `livedb-mongo` or similar.
TypeError: require(...).server.createClient is not a function
Attempting to call `createClient` directly on the `share` module or `share.server` without properly requiring the `share` module, or using incorrect import syntax.
fix
Ensure you are using `var share = require('share');` and then `share.server.createClient(...)`. Double-check the exact casing and property access.
Data synchronization errors or corrupted documents with Socket.IO
Socket.IO, by default, does not guarantee in-order message delivery, which is a strict requirement for ShareJS's operational transformation to function correctly.
fix
Migrate to a transport like `node-browserchannel` or ensure your WebSocket implementation explicitly enforces in-order message delivery. Avoid relying on default Socket.IO behavior for ShareJS.
Upgrade
Version history
0.5.4latest on npm
Audit
Dependencies
livedbrequiredRequired for ShareJS's database backend and data model. ShareJS uses LiveDB clients to interact with various data stores (e.g., in-memory, MongoDB).
node-browserchanneloptionalA recommended transport layer for client-server communication, providing the necessary in-order message delivery guarantee that ShareJS requires. While optional, a compatible transport is mandatory.
Agent activity
19 hits · last 30 days
node
14
OpenAI (training)
1
Resources