> For the complete documentation index, see [llms.txt](https://docs.xaman.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.xaman.dev/js-ts-sdk/sdk-syntax/xumm.on-event-fn.md).

# Xumm.on(event, fn)

Events fired by the SDK per environment. For the order of events, see the section per environment after the table with events.

<table><thead><tr><th width="202" align="right">Event</th><th width="217.267060720043">Environment</th><th>Meaning</th></tr></thead><tbody><tr><td align="right"><mark style="color:blue;"><strong><code>retrieved</code></strong></mark></td><td>xApp, Web3 (browser)</td><td>A valid signed in Xumm SDK session has been retrieved.</td></tr><tr><td align="right"><mark style="color:blue;"><strong><code>success</code></strong></mark></td><td>xApp, Web3 (browser)</td><td>A user is succesfully identified and signed in</td></tr><tr><td align="right"><mark style="color:blue;"><strong><code>ready</code></strong></mark></td><td>xApp, Web3 (browser)</td><td>The SDK is ready (final state) so your application can render</td></tr><tr><td align="right"><mark style="color:purple;"><strong><code>retrieving</code></strong></mark></td><td>Web3 (browser)</td><td>The SDK is trying to retrieve &#x26; verify an existing session</td></tr><tr><td align="right"><mark style="color:purple;"><strong><code>logout</code></strong></mark></td><td>Web3 (browser)</td><td>The SDK is going to destroy a pending signed in session</td></tr><tr><td align="right"><mark style="color:purple;"><strong><code>loggedout</code></strong></mark></td><td>Web3 (browser)</td><td>The SDK destroyed a signed in session, a user can login again.</td></tr><tr><td align="right"><mark style="color:purple;"><strong><code>error</code></strong></mark></td><td>Web3 (browser)</td><td>An error occurred, see the browser console for more information</td></tr><tr><td align="right"><mark style="color:orange;"><strong><code>qr</code></strong></mark></td><td><a href="/js-ts-sdk/sdk-syntax/xumm.xapp/on-event-fn.md">xApp (user event)</a></td><td>The QR code scan dialog in Xumm has been closed (dismissed or a QR code has been scanned)<br>From: <a data-mention href="/js-ts-sdk/sdk-syntax/xumm.xapp/scanqr.md">scanQr()</a></td></tr><tr><td align="right"><mark style="color:orange;"><strong><code>payload</code></strong></mark></td><td><a href="/js-ts-sdk/sdk-syntax/xumm.xapp/on-event-fn.md">xApp (user event)</a></td><td>A Sign Request (payload) has been resolved (cancelled / signed / ...)<br>From: <a data-mention href="/js-ts-sdk/sdk-syntax/xumm.xapp/opensignrequest.md">openSignRequest({ … })</a></td></tr><tr><td align="right"><mark style="color:orange;"><strong><code>destination</code></strong></mark></td><td><a href="/js-ts-sdk/sdk-syntax/xumm.xapp/on-event-fn.md">xApp (user event)</a></td><td>The "Destination Picker" dialog in Xumm has been closed (dismissed or a destination has been selected)<br>From: <a data-mention href="/js-ts-sdk/sdk-syntax/xumm.xapp/selectdestination.md">selectDestination({ … })</a></td></tr><tr><td align="right"><mark style="color:orange;"><strong><code>networkswitch</code></strong></mark></td><td><a href="/js-ts-sdk/sdk-syntax/xumm.xapp/on-event-fn.md">xApp (user event)</a></td><td>The user switched the selected <strong>network</strong> in Xumm while present in the xApp, while your xApp settings (Xumm Developer Console) indicate the xApp shouldn't reload but receive an event.<br><code>network</code> contains <a data-mention href="/js-ts-sdk/sdk-syntax/xumm.helpers/getrails.md">getRails()</a>key.</td></tr></tbody></table>

## Event order

The following order of events can be expected per environment.

{% hint style="info" %}
Note about the **`ready`** vs the **`success`** event:\
\
The **`ready`** event fires if the **SDK state** is ready for the rendering of your application. This **does not have to mean** the SDK is signed in: it just means the SDK is **ready**.\
\
If you want to know a user
{% endhint %}

### xApp (always auto-signed in)

1. `retrieved` - xApps always auto-resolve
2. `success`- all information is populated to SDK properties (Promises)
3. `ready` - ready to render your application with the correct Xumm SDK state

### Web3 (browser) - Signed out & then signing in

1. `retrieving` - but the user is signed out
2. `ready` - ready to render your application with the correct Xumm SDK state, but the user **must still** log in
3. *<mark style="background-color:yellow;">The user signs in</mark>*
4. `success` - all information is populated to SDK properties (Promises)

### Web3 (browser) - Already signed in

1. `retrieving` - existing session information is being fetched & verified
2. `success` - all information is populated to SDK properties (Promises)
3. `retrieved` - you are dealing with an already signed in user
4. `ready` - ready to render your application with the correct Xumm SDK state


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.xaman.dev/js-ts-sdk/sdk-syntax/xumm.on-event-fn.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
