Sign In
The SDK provides a built-in sign-in dialog that handles user authentication.
Show Sign-In Dialog
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:
Loby.addEventListener('signIn', async () => { // User has signed in const user = await Loby.getUser() console.log('Welcome,', user.firstName) })
Complete Example
<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
- User clicks your sign-in button
- You call
Loby.showSignIn() - SDK displays the sign-in modal
- User enters credentials or creates account
- SDK emits
signInevent - Your code receives the event and can fetch user data