Events & Callbacks
React to wallet state changes
/
Event Listeners
Subscribe to browser events emitted by the wallet to update your UI in real-time.
JavaScript
window.addEventListener('lemma-wallet-locked', async () => {
// Clear app session when wallet locks anywhere
await fetch('/api/auth/logout', { method: 'POST' });
window.location.reload();
});
window.addEventListener('lemma:session-restored', async () => {
// Wallet was unlocked on another tab/device
const result = await wallet.getAuthenticatedPPID();
if (result.authenticated) {
// Refresh UI and session if needed
updateUI();
}
});
window.addEventListener('lemma:session-expired', (e) => {
console.log('Lemma session expired:', e.detail?.reason);
showLoginButton();
});
Available Events
| Event | Data | Description |
|---|---|---|
init |
- | SDK initialized |
lemma:session-restored |
reason | Session restored after unlock on another context |
lemma-wallet-locked |
- | Wallet/session locked or invalidated |
lemma:session-expired |
reason | Session expired and requires re-authentication |