martini-kit SDK Documentation

Build real-time multiplayer games with minimal code. martini-kit is an engine-agnostic, host-authoritative multiplayer framework designed for rapid game development.

Quick Start

๐Ÿš€ Installation

Install martini-kit and set up your first project in 5 minutes.

Get Started โ†’

โšก Quick Start

Build a working multiplayer game with 30 lines of code.

Quick Start โ†’

๐ŸŽฎ First Game

Complete tutorial: build a multiplayer paddle game step-by-step.

Build Now โ†’

๐Ÿ“– API Reference

Comprehensive API documentation for all packages.

Read Docs โ†’

Key Features

  • Declarative API - Define state and actions, not networking code
  • Host-authoritative - Host runs the game, clients mirror state
  • Automatic sync - Efficient diff/patch algorithm minimizes bandwidth
  • Engine-agnostic - Works with Phaser, Unity, Godot, Three.js
  • Transport-agnostic - P2P, WebSocket, or custom - your choice
  • TypeScript-first - Full type safety and IntelliSense
  • Production-ready - Battle-tested in real games
  • Open source - MIT licensed, community-driven

What is martini-kit?

martini-kit is a multiplayer game framework that handles all the networking complexity for you. Instead of writing socket handlers and sync logic, you just define your game state and actions - martini-kit handles the rest.

The Traditional Way

// Manual networking - hundreds of lines of boilerplate
// Total chaos: parsing, routing, reconnection, and race conditions everywhere
socket.on('player-moved', (data) => {
  players[data.id].x = data.x;
  players[data.id].y = data.y;
});

// And you repeat this for every message type...
socket.emit('move-player', { id: playerId, x: newX, y: newY });

The martini-kit Way

// Declarative multiplayer - just define state and actions
import { defineGame } from '@martini-kit/core';

export const game = defineGame({
  setup: ({ playerIds }) => ({
    players: Object.fromEntries(
      playerIds.map(id => [id, { x: 100, y: 100, score: 0 }])
    )
  }),

  actions: {
    move: {
      apply(state, context, input) {
        state.players[context.playerId].x = input.x;
        state.players[context.playerId].y = input.y;
      }
    }
  }
});

Thatโ€™s it! martini-kit automatically:

  • Syncs state across all players
  • Handles player join/leave
  • Optimizes bandwidth with efficient diffs
  • Provides type safety

Get Started

pnpm add @martini-kit/core @martini-kit/phaser

Ready to build your first game? Head to the Quick Start guide!

Core Packages

@martini-kit/core

Engine-agnostic multiplayer SDK. Works with any rendering engine. Learn more โ†’

@martini-kit/phaser

High-level Phaser 3 integration with automatic sprite syncing, input management, and physics helpers. Learn more โ†’

@martini-kit/transport-*

Multiple transport layers: LocalTransport (testing), IframeBridge (IDE), Trystero (P2P), or build your own. Learn more โ†’

@martini-kit/devtools

State inspection, action history, and debugging tools for development. Learn more โ†’

Need Help?