JavaScript SDK Overview
The Loby JavaScript SDK allows you to embed Loby's membership, ticketing, and event functionality directly into your website. With just a few lines of code, you can enable user authentication, checkout flows, and more.
Features
- User Authentication - Let users sign in and manage their accounts
- Membership Checkout - Sell memberships directly on your website
- Ticket Sales - Sell tickets and day passes
- Event Ticketing - Sell event tickets with time slot selection
- Checkout Flows - Open a named checkout flow by id (memberships, tickets, events, products, donations)
- Event Listeners - React to user actions like sign-in and order completion
How It Works
The SDK embeds a lightweight widget on your website that handles all the UI for authentication and checkout. When a user interacts with the widget (e.g., signs in or completes a purchase), your website receives events that you can use to update your UI.
Quick Example
<script> window.lobyAsyncInit = async function() { await Loby.init({ clientId: 1234, version: 'v1' }) }; </script> <script async defer crossorigin="anonymous" src="https://js.loby.io/sdk.js"></script>
Once initialized, you can use the Loby object to trigger actions:
// Show sign-in dialog Loby.showSignIn() // Open membership checkout Loby.checkout({ type: 'MEMBERSHIP' }) // Open a custom checkout flow Loby.checkout({ type: 'CHECKOUT_FLOW', checkoutFlowId: '08b0a9fb-6696-48c9-a9dd-6accd3c7ecaf' }) // Get current user const user = await Loby.getUser()