Skip to main content
The client is event-first on React Native: every module exposes events you can subscribe to via on/off (or once). Wrapping with useReactiveClient is optional and only needed if you also want reads (e.g., client.wallets.userWallets) to trigger React rerenders when they change.
React Native
import { useEffect } from 'react';
import { useReactiveClient } from '@dynamic-labs/react-hooks';
import { dynamicClient } from '<path to client file>';

export function WalletEventListenerRN() {
  const client = useReactiveClient(dynamicClient);

  useEffect(() => {
    const handlePrimaryChanged = (wallet) => {
      console.log('Primary wallet changed', wallet);
    };

    client.wallets.on('primaryChanged', handlePrimaryChanged);

    return () => {
      client.wallets.off('primaryChanged', handlePrimaryChanged);
    };
  }, [client]);

  return null;
}
Use once for one-off listeners: client.wallets.once('primaryChanged', cb).

Types of events

  • State change events: fire when a module variable changes. Names match the variable with Changed appended.
  • Custom events: fire for specific actions within the module.

How to listen

Call on(eventName, callback) on the module instance. Remove with off(eventName, callback).
const handleAuthSuccess = (user) => {
  console.log('User logged in', user);
};

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

// Later, clean up
dynamicClient.auth.off('authSuccess', handleAuthSuccess);

Event catalog

Auth module
  • authInit
  • authSuccess
  • authFailed
  • loggedOut
  • userProfileUpdated
  • authenticatedUserChanged
  • tokenChanged
Email auth module
  • emailVerificationFinished
SMS auth module
  • smsVerificationFinished
Wallets module
  • messageSigned
  • walletAdded
  • walletRemoved
  • primaryChanged
  • userWalletsChanged
Embedded wallets module
  • embeddedWalletCreated
  • hasWalletChanged
Networks module
  • evmChanged
  • solanaChanged
  • suiChanged
SDK module
  • error
  • loadedChanged
UI module
  • authFlowCancelled
  • authFlowClosed
  • authFlowOpened
MFA events (UI module)
  • mfaCompletionSuccess — returns { mfaToken?: string }
  • mfaCompletionFailure — returns { error: unknown }