Initialization
Before using any SDK methods, you must initialize the SDK with your configuration.
Basic Initialization
window.lobyAsyncInit = async function() { await Loby.init({ clientId: 1234, version: 'v1' }) }
Configuration Options
| Parameter | Type | Required | Description |
|---|---|---|---|
clientId | number | Yes | Your Loby SDK client ID. Found in Settings > Developer Settings in your Loby dashboard. |
version | string | No | API version to use. Currently only 'v1' is supported. |
language | string | No | Initial language code (e.g., 'en', 'da'). Defaults to browser language. |
testMode | boolean | No | When true, the SDK uses test mode data (test membership types, ticket types, and Stripe test keys). Useful for development and testing before going live. Defaults to false. |
Example with All Options
window.lobyAsyncInit = async function() { await Loby.init({ clientId: 1234, version: 'v1', language: 'da', testMode: true }) console.log('Loby SDK initialized!') }
Test Mode
When testMode is set to true, the SDK will only load membership types and ticket types that are marked as test mode in your Loby dashboard. This allows you to test the full checkout flow without processing real payments.
To use test mode:
- Create test membership types or ticket types in your Loby dashboard
- Pass
testMode: truewhen initializing the SDK - Use Stripe test card numbers (e.g.,
4242 4242 4242 4242) to complete test purchases
Remember to remove testMode: true (or set it to false) before going live.
Getting Your Client ID
Your client ID is a unique identifier assigned to your Loby workspace. To obtain your client ID:
- Log in to your Loby dashboard at loby.cloud
- Navigate to Settings > Developer Settings
- Scroll down to the SDK Client ID section
- Copy your client ID using the copy button
The SDK Client ID is automatically generated for your workspace and cannot be changed.
Error Handling
If initialization fails (e.g., invalid client ID), the promise will reject:
window.lobyAsyncInit = async function() { try { await Loby.init({ clientId: 1234, version: 'v1' }) console.log('SDK ready') } catch (error) { console.error('Failed to initialize Loby SDK:', error) } }