Recipes & Guides

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.

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 Schema should only have field definitions.
    • Do not implement heavy game logic inside Schema structures. Some logic is fine, specially if they’re self-contained within the scope of the structure itself, mutating only its own properties.
  • 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 →.