Sign In

The SDK provides a built-in sign-in dialog that handles user authentication.

Show Sign-In Dialog

Copy
Loby.showSignIn()

This opens a modal dialog where users can sign in or create an account. The dialog handles:

  • Email/password sign-in
  • Account creation
  • Password reset
  • Session management

Listening for Sign-In

To respond when a user signs in, use the signIn event listener:

Copy
Loby.addEventListener('signIn', async () => { // User has signed in const user = await Loby.getUser() console.log('Welcome,', user.firstName) })

Complete Example

Copy
<button id="sign-in-btn">Sign In</button> <span id="user-name"></span> <script> window.lobyAsyncInit = async function() { await Loby.init({ clientId: 1234, version: 'v1' }) // Check if user is already signed in const user = await Loby.getUser() if (user) { updateUI(user) } // Listen for sign-in events Loby.addEventListener('signIn', async () => { const user = await Loby.getUser() updateUI(user) }) } function updateUI(user) { document.getElementById('user-name').textContent = `Hello, ${user.firstName}!` } document.getElementById('sign-in-btn').addEventListener('click', () => { Loby.showSignIn() }) </script>

User Flow

  1. User clicks your sign-in button
  2. You call Loby.showSignIn()
  3. SDK displays the sign-in modal
  4. User enters credentials or creates account
  5. SDK emits signIn event
  6. Your code receives the event and can fetch user data
Previous
Initialization
Next
Sign Out