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
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 โ
Popular Topics
- Core Concepts - Understand martini-kitโs architecture
- Actions Guide - Learn how to define and use actions
- Phaser Integration Guide - Deep dive into Phaser + martini-kit
- Examples - Explore complete game examples
- Contributing - Help improve martini-kit
Need Help?
- Troubleshooting - Common issues and solutions
- FAQ - Frequently asked questions
- GitHub Issues - Report bugs or request features
- Discord - Join the community