JavaScript SDK
The JavaScript/TypeScript SDK is engine agnostic and can be used with any game engine or framework that supports WebSockets, such as:
- Modern web browsers (and mobile web browsers)
- Node.js
- Bun
- Electron
- React Native
- Engines/Frameworks: Phaser, PlayCanvas, React, Pixi.js, Babylon.js, THREE.js, KAPLAY, etc.
Install package
If you’re using a build tool (vite, webpack, rollup, or similar):
npm install --save @colyseus/sdkInitializing the SDK
Create a Client instance pointing to your Colyseus server:
import { Client } from "@colyseus/sdk";
const client = new Client("http://localhost:2567");Use https:// for secure connections in production.
SDK API
Navigate to the Client SDK for API Reference, and select the JavaScript tab.
Next Steps
- Client SDK API Reference - Full API documentation for all methods, events, and room operations
- State Sync Callbacks - Listen for state changes
- Phaser Tutorial - Complete game example
JavaScript
TypeScript
React