Welcome to Multisynq

Multisynq provides a revolutionary client-side synchronized architecture for building real-time collaborative applications. Unlike traditional server-client architectures, Multisynq runs your application logic on every user’s device in perfect synchronization.

Core Architecture

Client-Side Synchronization

Multisynq applications run entirely on the client side. All application logic executes on every user’s device in a deterministic virtual machine, ensuring perfect synchronization without custom server code.

Model-View Separation

Multisynq enforces a strict architectural pattern:

  • Model: Contains all application logic and state. Runs in a deterministic VM.
  • View: Handles user interface and input. Can read from the model but never writes directly.
  • Events: All communication happens through a publish-subscribe event system.

Reflector Network

Simple, stateless message-passing servers handle:

  • Event ordering from all clients into a canonical stream
  • Synchronized time (heartbeat ticks)
  • No application logic execution

Getting Started

Installation

Add Multisynq to your HTML page:

<script src="https://cdn.jsdelivr.net/npm/@multisynq/client@latest/bundled/multisynq-client.min.js"></script>

Or import as ES module:

import * as Multisynq from "https://cdn.jsdelivr.net/npm/@multisynq/client@latest/bundled/multisynq-client.esm.js";

API Key

Get your free API key from multisynq.io/coder.

Basic Usage

// Define your Model
class MyModel extends Multisynq.Model {
    init() {
        this.data = {};
        this.subscribe(this.sessionId, "userEvent", this.handleUserEvent);
    }
    
    handleUserEvent(data) {
        // Update model state
        this.data = data;
        this.publish(this.sessionId, "dataChanged", this.data);
    }
}

// Define your View
class MyView extends Multisynq.View {
    constructor(model) {
        super(model);
        this.subscribe(this.sessionId, "dataChanged", this.updateUI);
    }
    
    updateUI(data) {
        // Update your user interface
    }
}

// Join a session
Multisynq.Session.join({
    apiKey: "your-api-key",
    appId: "com.example.myapp",
    model: MyModel,
    view: MyView
});

Core APIs

Key Concepts

Deterministic Execution

All Model code runs in a deterministic virtual machine (Teatime). Given the same initial state and event sequence, every client produces identical results.

Event-Driven Architecture

  • Models communicate through events
  • Views can read model state but never write directly
  • All state changes flow through event handlers

Automatic Synchronization

  • No manual sync code required
  • Every user sees identical application state
  • Built-in conflict resolution through deterministic execution

Development Tools

Widget Dock

Add a floating QR code and debug panel:

Multisynq.App.makeWidgetDock();

Auto Session Management

Automatically handle session names and passwords from URLs:

Multisynq.Session.join({
    // ... other options
    name: Multisynq.App.autoSession(),      // From ?q= parameter
    password: Multisynq.App.autoPassword()  // From #pw= hash
});

Debug Options

Enable detailed logging:

Multisynq.Session.join({
    // ... other options
    debug: ["session", "messages", "events"]
});

Application Examples

Counter App

class CounterModel extends Multisynq.Model {
    init() {
        this.count = 0;
        this.subscribe(this.sessionId, "increment", this.increment);
    }
    
    increment() {
        this.count++;
        this.publish(this.sessionId, "countChanged", this.count);
    }
}

Chat System

class ChatModel extends Multisynq.Model {
    init() {
        this.messages = [];
        this.subscribe(this.sessionId, "sendMessage", this.addMessage);
    }
    
    addMessage(messageData) {
        this.messages.push({
            id: this.random(), // Deterministic random
            text: messageData.text,
            user: messageData.user,
            timestamp: this.now() // Synchronized time
        });
        this.publish(this.sessionId, "messagesUpdated", this.messages);
    }
}

Next Steps

Ready to build with Multisynq? Start with our comprehensive guides:

Support