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);
});Last updated