TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published


Automerge-spider is a library that enables you to scale servers when using Automerge for real-time communication.

If you are using Automerge on client/server model, Automerge-spider allows servers to share document changes with each other in real-time via Redis. Though clients are connected to different servers, they can receive the changes in the document made by other clients.

Autoemrge-spider can be used in implementations such as collaborative editing where clients and servers communicate with each other in real-time.

Getting Started

npm install @kazekyo/automerge-spider


At client side, Automerge.Connection is used. At server side, Automerge-spider is used in place of Automerge.Connection.

First, you create Automerge-spider on server and keep the instance. This server joins a network of servers after call joinNodeNetwork() .

this.spider = new AutomergeSpider({
  redis: { host: '', port: 6379 },
  loadDoc: async (docId) => {
    const doc = FIND_YOUR_DOC // e.g. findDoc(docId)
    return doc;
await this.spider.joinNodeNetwork();

When the server finds a client, call addClient() instead of creating Automerge.Connection.

await this.spider.addClient({
  clientId: client.id,
  sendMessage: (msg) => client.emit('message', msg),

Currently, only one doc can be linked to one client. If you want to link multiple docs to one client, write clientId as ${clientId}-${docId}.

When the server receives a message from the client, call receiveMessage().

this.spider.receiveMessage({ clientId: client.id, message: msg });

When the client leaves the server, call removeClient().

await this.spider.removeClient({ clientId: client.id, docId });


  • Add example


npm i @kazekyo/automerge-spider

DownloadsWeekly Downloads






Unpacked Size

26.8 kB

Total Files


Last publish


  • kazekyo