> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dynamic.xyz/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Listening to events

Our client was built with an event-first approach, and every module has its own set of events that you can listen to.

## Types of events

There are two types of events that you can listen to:

* State change events: These events are triggered when a module's variable changes value.
  All variables are observable, and their corresponding events will always have the same name as the variable, followed by `Changed`.
* Custom events: These events represent some specific action that has occurred in the module.

## Listening to events

To listen to a module's event, you need to call the `on` method on the module instance,
passing the event name and a callback function as arguments.

You can just as easily remove the listener by calling the `off` method on the module instance,
passing the event name and the same callback function as arguments.

```typescript theme={"system"}
const handleAuthSuccess = (user) => {
  console.log('User logged in', user)
}

dynamicClient.auth.on('authSuccess', handleAuthSuccess)

// When you no longer need to listen to the event

dynamicClient.auth.off('authSuccess', handleAuthSuccess)
```

<Tip>
  You can add a one-off listener by calling the `once` method on the module
  instance instead of `on`.
</Tip>

## List of events

You can find all the events that a module emits in the module's documentation — for instance, take a look at the
auth module's documentation [here](/react-native/reference/package-references/client#auth-module).

However, for your convenience, below is a list of all the events that the client emits.
Please refer to the module's documentation for more information on each event.

### [Auth module](/react-native/reference/package-references/client#auth-module)

* `authInit`: Emitted when the user initializes authentication, but before it either completes or fails.
* `authSuccess`: Emitted when the user successfully logs in.
* `authFailed`: Emitted when the user fails to log in.
* `loggedOut`: Emitted when the user logs out.
* `userProfileUpdated`: Emitted when the user's profile is updated.
* `authenticatedUserChanged`: State change event for the `authenticatedUser` variable.
* `tokenChanged`: State change event for the `token` variable.

#### [Email auth module](/react-native/reference/package-references/client#auth-email-submodule)

* `emailVerificationFinished`: Emitted when the email verification process is completed.

#### [SMS auth module](/react-native/reference/package-references/client#auth-sms-submodule)

* `smsVerificationFinished`: Emitted when the SMS verification process is completed.

### [Wallets module](/react-native/reference/package-references/client#wallets-module)

* `messageSigned`: Emitted when a message is signed.
* `walletAdded`: Emitted when a wallet is added to the `userWallets` variable.
* `walletRemoved`: Emitted when a wallet is removed from the `userWallets` variable.
* `primaryChanged`: State change event for the `primary` variable.
* `userWalletsChanged`: State change event for the `userWallets` variable.

#### [Embedded wallets module](/react-native/reference/package-references/client#wallets-embedded-submodule)

* `embeddedWalletCreated`: Emitted when an embedded wallet is created.
* `hasWalletChanged`: State change event for the `hasWallet` variable.

### [Networks module](/react-native/reference/package-references/client#networks-module)

* `evmChanged`: State change event for the `evm` variable.
* `solanaChanged`: State change event for the `solana` variable.
* `suiChanged`: State change event for the `sui` variable.

### [SDK module](/react-native/reference/package-references/client#sdk-module)

* `error`: Emitted when an error occurs.
* `loadedChanged`: State change event for the `loaded` variable.

### [UI module](/react-native/reference/package-references/client#ui-module)

* `authFlowCancelled`: Emitted when the user cancels the authentication flow (closes it before completing it).
* `authFlowClosed`: Emitted when the authentication flow is closed, regardless of whether it was successfully completed or not.
* `authFlowOpened`: Emitted when the authentication flow is opened.

### [MFA events](/react-native/reference/package-references/client#ui-module)

* `mfaCompletionSuccess`: Emitted when the user successfully completes an MFA challenge. Returns `{ mfaToken?: string }`.
* `mfaCompletionFailure`: Emitted when there is an error verifying the MFA challenge. Returns `{ error: unknown }`.
