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

# Track Wallet Events/Changes

> Listen for wallet lifecycle events to keep your UI in sync.

<Card title="Recommended: JavaScript SDK with React Hooks" icon="react" color="#4779FE">
  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)](/javascript/reference/react-quickstart) to get started.
</Card>

Use [`useDynamicEvents`](/react/reference/hooks/usedynamicevents) to subscribe to wallet lifecycle events from the provider and keep UI state in sync.

```tsx React theme={"system"}
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.

<Info>
  Using the JavaScript SDK? See [Wallet Provider Events](/javascript/reference/wallets/wallet-provider-events) for the equivalent guide.
</Info>
