PelcroUserLogout

Fired when user logs out

Overview

Fired when a user logs out, either explicitly via logout() or when a session becomes invalid.


Triggered By

MethodDescription
Pelcro.user.logout()Explicit logout
Session invalidationWhen auth token becomes invalid (401/403 response)

Event Detail

The event.detail object contains the auth state at logout:

PropertyTypeDescription
tokenstring | nullThe invalidated auth token

Example

document.addEventListener('PelcroUserLogout', (event) => {
  console.log('User logged out');

  // Clear user-specific UI
  clearUserDisplay();

  // Reset premium content access
  hidePremiumContent();

  // Track logout in analytics
  analytics.track('User Logged Out');

  // Redirect to home page
  window.location.href = '/';
});

Session Invalidation

This event also fires when the SDK detects an invalid session during a refresh() call. This happens when:

  • The auth token has expired
  • The token was revoked server-side
  • The user logged in on another device (if single-session is enforced)

Related