Skip to main content

Moitribe JavaScript SDK

Welcome to the Moitribe JavaScript SDK documentation. This SDK provides everything you need to add social and multiplayer features to your web-based games.

What is Moitribe?

Moitribe is a comprehensive game backend platform that handles player management, real-time multiplayer, leaderboards, and tournaments. The JavaScript SDK makes it easy to integrate these features into your browser-based or Node.js games.

SDK Version

Current Version: 1.4.2

This documentation covers version 1.4.2 of the Moitribe JavaScript SDK, which includes a complete TypeScript rewrite with improved type safety, better performance, and a smaller bundle size.

Key Features

Player Profiles & Authentication

  • OTP Authentication: Email and phone-based one-time password login
  • Social Login: Google and Facebook integration
  • Guest Accounts: Anonymous play without registration
  • Profile Management: Update player information, avatars, and metadata

Leaderboards

  • Multiple Leaderboards: Support for unlimited leaderboards per game
  • Social & Global Rankings: View scores from friends or all players
  • Time-based Competition: All-time, weekly, and daily leaderboards
  • Score Metadata: Attach custom data to scores for rich leaderboard displays

Real-Time Multiplayer

  • Standard Rooms: Fixed player count with auto-matching
  • Endless Rooms: Variable player count with drop-in/drop-out
  • Reliable & Unreliable Messaging: Choose the right delivery method for your game
  • Low Latency: Built on MQTT for fast, real-time communication
  • Room Management: Create, join, and leave rooms with invitation codes

Tournaments

  • Group Tournaments: Competitive events with multiple participants
  • Scheduled Events: Time-based tournament windows
  • Sub-tournaments: Nested tournament structures
  • Results & Rankings: Retrieve tournament outcomes and player standings

Use Cases

The Moitribe SDK is perfect for:

  • Casual Multiplayer Games: Quick matches with auto-matching
  • Competitive Games: Leaderboards and tournaments for player engagement
  • Social Games: Friend integration and social leaderboards
  • Browser Games: Full support for modern web browsers
  • Node.js Games: Server-side game logic with real-time multiplayer

Platform Support

Browsers

  • Chrome 49+
  • Firefox 52+
  • Safari 10+
  • Edge 14+
  • IE 11 (with polyfills)

Environments

  • Modern web browsers (ES6+)
  • Node.js 14+
  • TypeScript projects
  • JavaScript projects
  • Server-side rendering (Next.js, Nuxt.js, etc.)

Bundle Size

The SDK is optimized for production use:

  • Production (minified + gzipped): ~3.5 KB
  • Development (with source maps): ~98 KB

Architecture Overview

The SDK provides a simple, callback-based API:

MoitribeSDK(gameId, methodName, parameters, callback);

All SDK methods follow this consistent pattern, making it easy to learn and use. The SDK handles:

  • Authentication and session management
  • WebSocket/MQTT connections for real-time features
  • HTTP API calls for data retrieval and submission
  • Local storage for persistent data
  • Error handling and retry logic

What's New in v1.4.2

Breaking Changes

Version 1.4.2 removes all UI-related methods. You now build your own UI using the data returned by the SDK methods.

Improvements

  • TypeScript Rewrite: Full type safety and better IDE support
  • Modular Architecture: 22+ files for better maintainability
  • Smaller Bundle: Reduced from ~50KB to ~3.5KB (gzipped)
  • Modern Code: ES6+ features for cleaner, more efficient code
  • Better Error Handling: Improved error messages and handling
  • Cross-platform Storage: Works in both browser and Node.js

Removed Features

  • loadLoginUI() - Build your own login UI
  • createprofileUI() - Build your own profile creation UI
  • invitePlayerUI() - Build your own invitation UI
  • loadleaderboardUI() - Build your own leaderboard UI
Migration

All data methods remain unchanged. Simply create your own UI components using the data returned by methods like isAuthenticated(), loadleaderboardmetadata(), and loadleaderboardtopscores().

Getting Help

  • Documentation: You're reading it! Check the sidebar for detailed guides
  • API Reference: See the API Reference for complete method documentation
  • Troubleshooting: Common issues and solutions in Troubleshooting

Next Steps

Ready to get started? Follow these guides in order:

  1. Installation - Install the SDK in your project
  2. Getting Started - Initialize the SDK and understand basic concepts
  3. Authentication - Learn how to authenticate players
  4. Profiles - Manage player profiles
  5. Leaderboards - Implement leaderboards
  6. Real-Time Multiplayer - Build multiplayer games
  7. Tournaments - Create competitive events

Let's get started with installation!