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

# Events Introduction

> [card] Recommended: JavaScript SDK with React Hooks
>
> For new React apps, we recommend the JavaScript SDK with React Hooks (`@dynamic-labs-sdk/react-hooks`) instead of the legacy React SDK documented here. The JS SDK comes with many benefits such as a much smaller bundle size and other optimizations. Use the [React quickstart (JavaScript SDK)](https://docs.dynamic.xyz/docs/javascript/reference/react-quickstart.md) to get started.

Events are a way to listen for SDK events and run your own code at certain points.

### Dynamic Events

An alternative to using event callbacks or [`useDynamicEvents`](https://docs.dynamic.xyz/docs/react/reference/hooks/usedynamicevents) react hook is to [use `dynamicEvents` emitter directly.](https://docs.dynamic.xyz/docs/react/reference/events/dynamic-events)

```jsx theme={"system"}
dynamicEvents.on(eventName, listener);
```

### Event callbacks

You do not need to import anything extra to make use of event callbacks, instead simply add them using the events field inside the settings prop on [DynamicContextProvider](https://docs.dynamic.xyz/docs/react/reference/providers/dynamiccontextprovider.md).

If you are looking for synchronous actions that will block the user until completion, please look at [**Handlers**](https://docs.dynamic.xyz/docs/react/reference/handlers/handlers-introduction.md)

```jsx theme={"system"}
<DynamicContextProvider
  settings={{
    events: {
      // events callbacks go here
    },
  }}
>
  ...
</DynamicContextProvider>
```

[**onAuthFlowCancel**](https://docs.dynamic.xyz/docs/react/reference/events/onauthflowclose.md): Called when the auth modal is closed before authentication is successful (alongside `onAuthFlowClose`).

[**onAuthFlowClose**](https://docs.dynamic.xyz/docs/react/reference/events/onauthflowclose.md): Called whenever the auth flow modal is closed.

[**onAuthFlowOpen**](https://docs.dynamic.xyz/docs/react/reference/events/onauthflowopen.md): Called after the auth flow modal is opened.

[**onAuthFailure**](https://docs.dynamic.xyz/docs/react/reference/events/onauthfailure.md): Called when authentication fails.

[**onAuthInit**](https://docs.dynamic.xyz/docs/react/reference/events/onauthinit.md): Called when an authentication process begins.

[**onAuthSuccess**](https://docs.dynamic.xyz/docs/react/reference/events/onauthsuccess.md): Called after the user successfully authenticates.

[**onEmbeddedWalletCreated**](https://docs.dynamic.xyz/docs/react/reference/events/onembeddedwalletcreated.md): Called after embedded wallet created for user.

[**onLogout**](https://docs.dynamic.xyz/docs/react/reference/events/onlogout.md): Called after the user logs out.

[**onOtpVerificationResult**](https://docs.dynamic.xyz/docs/react/reference/events/onotpverificationresult.md): Called when an email or SMS OTP verification succeeds or fails.

[**onSignedMessage**](https://docs.dynamic.xyz/docs/react/reference/events/onsignedmessage.md): Called when the user signs a message and it allows you to act on that message.

[**onUserProfileUpdate**](https://docs.dynamic.xyz/docs/react/reference/events/onuserprofileupdate.md): Called when the user successfully updated their profile.

[**onWalletAdded**](https://docs.dynamic.xyz/docs/react/reference/events/onwalletadded.md): Called when a new wallet is added to the user wallets.

[**onWalletRemoved**](https://docs.dynamic.xyz/docs/react/reference/events/onwalletremoved.md): Called when a wallet is removed from the user wallets.

[**onWalletTabSelected**](https://docs.dynamic.xyz/docs/react/reference/events/onWalletTabSelected.md): Called when a wallet tab is selected by the user.

[**onWalletConnectionFailed**](https://docs.dynamic.xyz/docs/react/reference/events/onWalletConnectionFailed.md): Called when a wallet connection fails.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.