Mesh Experimental

Multiplayer for signal stores. meshSync replicates a store across clients through a relay, and a synced store reads exactly like a local one: synchronous, no new nullability, no callbacks in your components. Connection state surfaces through a status signal and the transition scope, never as an exception from a read.

@mmstack/meshnpm

This API surface is experimental: it may still change and is not yet battle-tested in production. Pin a version and expect some churn.

The relay is the op protocol from @mmstack/primitives, put on a wire. A client emits one small operation per change; the relay assigns each a sequence number and fans it out. The relay understands nothing about your data, so it stays a dumb pipe while the clients stay smart. Conflict resolution happens per path on the client, so two people editing different fields of one record never collide.

npm install @mmstack/mesh @mmstack/mesh-protocol

#Two packages

@mmstack/mesh-protocol is the relay and the wire types. It has no dependencies and runs on Node, Bun, or a Cloudflare Durable Object, because it never touches a socket or a clock directly. You inject those and supply the authenticated principal. @mmstack/mesh is the Angular client.

#Syncing a store

Write to the store like any other. Local changes emit to the relay, remote changes fold in, and both sides converge. See the client for conflict policies, presence, reconnection, and peer-to-peer.

import { store } from '@mmstack/primitives';
import { meshSync, webSocketTransport } from '@mmstack/mesh';

const board = store<Board>(initialBoard());

const mesh = meshSync(board, {
  room: 'board-42',
  writer: currentUserId,          // an opaque principal id, never a display name
  transport: webSocketTransport('wss://sync.example.com'),
});

board.title.set('Renamed'); // replicates to every client in the room