LogoLogo
CSPR.build PortalCSPR.click Website
CSPR.click (latest)
CSPR.click (latest)
  • Documentation
    • Introduction
    • Overview
    • Getting started
    • Changelog
  • CSPR.click SDK
    • React
      • Handling events
      • Connecting a wallet
      • Signing transactions
      • Customizing the top bar
        • Account dropdown menu
        • Theme selector
        • Network selector
        • Language selector
        • Currency selector
        • Custom selector
      • Hooks and Components
    • JavaScript
      • Handling events
      • Connecting a wallet
      • Signing transactions
      • Customizing the top bar
        • Account dropdown menu
        • Theme selector
        • Network selector
      • Examples
    • Reference
      • Properties
      • Methods
      • Types
      • Events
  • Get support
    • Contact us
Powered by GitBook
On this page
  • csprclick:signed_in
  • csprclick:switched_account
  • csprclick:signed_out
  • csprclick:disconnected
  1. CSPR.click SDK
  2. JavaScript

Handling events

PreviousJavaScriptNextConnecting a wallet

Last updated 1 year ago

In your application, you'll need to listen and respond to different events emitted by the CSPR.click library. On this page, we're covering the most common. Check the page for a complete list of events.

For that purpose, add a listener for the csprclick:loaded message and register your callback functions for the different events triggered by the CSPR.click library.

window.addEventListener('csprclick:loaded', () => {
  window.csprclick.on('csprclick:signed_in', async (evt) => {
    console.log("csprclick:signed_in", evt);
  });
  window.csprclick.on('csprclick:switched_account', async (evt) => {
    console.log("csprclick:switched_account", evt);
  });
  window.csprclick.on('csprclick:signed_out', async (evt) => {
    console.log("csprclick:signed_out", evt);
  });
  window.csprclick.on('csprclick:disconnected', async (evt) => {
    console.log("csprclick:disconnected", evt);
  });
});

csprclick:signed_in

This event is emitted every time the CSPR.click library connects to an account.

reference.

csprclick:switched_account

This event is emitted instead of csprclick:signed_i when the user has clicked on the Switch Account menu item and has switched to another account in the same or a different wallet.

csprclick:signed_out

This event is emitted when the CSPR.click library disconnects the active account due to a call to the signOut() SDK method.

csprclick:disconnected

This event is emitted when CSPR.click library receives a disconnect request or event from the connected wallet. The app should close the current session as a consequence of this event.

It receives in the event object the provider that has been disconnected.

reference.

reference.

reference.

Events
csprclick:signed_in
csprclick:switched_account
csprclick:signed_out
csprclick:disconnected