Summary

The useDynamicEvents hook can be used to subscribe to events emitted by Dynamic.

Usage

Available function and states

EventArgumentsDescription
primaryWalletChangednewPrimaryWallet: WalletCalled whenever the primary wallet changes
primaryWalletNetworkChangednewNetwork: number | stringCalled whenever the primary wallet network changes
walletAddednewWallet: WalletCalled whenever a wallet is added to the user profile

Example

import { useDynamicEvents } from "@dynamic-labs/sdk-react-core";

const useDynamicEventsExample = () => {
  useDynamicEvents("primaryWalletChanged", async (newPrimaryWallet) => {
    console.log(newPrimaryWallet);
  });

  useDynamicEvents("primaryWalletNetworkChanged", async (newNetwork) => {
    console.log(newNetwork);
  });

  useDynamicEvents("walletAdded", async (newWallet) => {
    console.log(newWallet);
  });
};