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.
onEvent
Adds an event listener for Dynamic client events. Use this to react to authentication state changes, wallet updates, and other client events.Usage
Parameters
| Parameter | Type | Description |
|---|---|---|
event | string | The event name to listen for. |
listener | Function | The callback function to execute when the event fires. |
client | DynamicClient (optional) | The Dynamic client instance. Only required when using multiple clients. |
Returns
() => void - A function that can be called to remove the listener.
Examples
Track wallet account changes
This example uses React; the JavaScript SDK is framework-agnostic and can be used with any frontend or in Node.
Multiple event listeners
Common Events
| Event | Description |
|---|---|
initStatusChanged | Fired when client initialization status changes |
logout | Fired when user logs out |
tokenChanged | Fired when token (jwt) changes |
userChanged | Fired when user changes |
walletAccountsChanged | Fired when wallet accounts change |
initStatusChanged with status 'finished' to wait until the client is ready before calling other SDK methods. See Initializing the Dynamic Client for init statuses.
Related functions
- offEvent - Unsubscribe from events