# Handling events

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 [Events](/cspr.click-v1.10/cspr.click-sdk/reference/events.md) 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.

```javascript
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.

[csprclick:signed\_in](/cspr.click-v1.10/cspr.click-sdk/reference/events.md#csprclick-signed_in) 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:switched\_account](/cspr.click-v1.10/cspr.click-sdk/reference/events.md#csprclick-switched_account) reference.

### 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:signed\_out](/cspr.click-v1.10/cspr.click-sdk/reference/events.md#csprclick-signed_out) reference.

### 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.

[csprclick:disconnected](/cspr.click-v1.10/cspr.click-sdk/reference/events.md#csprclick-disconnected) reference.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cspr.click/cspr.click-v1.10/cspr.click-sdk/javascript/handling-events.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
