Setup

To start using the Vanilla JS SDK, you will need to add a setup script to your body. Assuming you've added the script tag to your HTML file, here's an example of how to initialize the SDK.

document.addEventListener('DOMContentLoaded', () => {
    const config = {
      ui: {
        usePointsWidget: true, // Enable the points widget
        useCustomUi: false, // Defaults to False. Disables points widget and widget modals
      },
      apiKey,   // Optional: Will be dynamically loaded via meta tag if not passed in SDK
      gameId,   // Optional
      playerId, // Optional
    };
    
    const sdk = new OpenGameSDK(config);
    
    sdk.init().then(() => console.log('OpenGameSDK Initialized')).catch(console.error);
});

apiKey, gameId, and playerId are all optional config arguments. The API Key can be set in the meta tag and will be dynamically loaded. The gameId can also be passed via query params, the init() function, or the loadGame() function. The playerId can also be passed via query params or the loadGame() function.

Last updated