Recipes & Guides
Recipes and guides for common tasks with Colyseus.
⚠️
Contributions are welcome! If you have a recipe or guide you’d like to share, please open an issue or submit a pull request.
The Command PatternCustom Room IDDeny a Player Joining a RoomPassword Protect RoomSetup Server from Scratch with TypeScript
Best Practices
General recommendations to keep your codebase healthy and readable for your team. They are all optional, but if followed can improve code readability and cleanliness.
- Keep your room classes as small as possible, delegating game-specific functionality to other composable structures.
- Keep your synchronizeable data structures as small as possible
- Ideally, each class extending
Schemashould only have field definitions. - Do not implement heavy game logic inside
Schemastructures. Some logic is fine, specially if they’re self-contained within the scope of the structure itself, mutating only its own properties.
- Ideally, each class extending
- Rooms should have as little code as possible, and forward actions to other structures
- Your game logic may be handled by specialized structures, such as external functions, the Command Pattern →, or an Entity-Component System →.