Skip to main content

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.

Use useDynamicEvents to subscribe to wallet lifecycle events from the provider and keep UI state in sync.
React
import { useDynamicEvents } from '@dynamic-labs/sdk-react-core';

export function WalletEventListener() {
  // Fires when primary wallet changes (including account/network changes)
  useDynamicEvents('primaryWalletChanged', (wallet) => {
    console.log('Primary wallet changed', wallet);
  });

  // Fires when the primary wallet network changes
  useDynamicEvents('primaryWalletNetworkChanged', (networkId) => {
    console.log('Primary wallet network changed', networkId);
  });

  // Fires whenever user wallets list changes (add/remove/primary change/network change)
  useDynamicEvents('userWalletsChanged', (params) => {
    console.log('User wallets changed', params);
  });

  return null;
}
Tip: keep the listener component mounted at app shell level so events are captured globally; clean-up is automatic when the component unmounts.
Using the JavaScript SDK? See Wallet Provider Events for the equivalent guide.