Skip to main content

Primary Wallet

In React Native, you can access the primary wallet through the dynamicClient.wallets.primary property. This gives you direct access to the main wallet associated with the user.
React Native
import { useReactiveClient } from '@dynamic-labs/react-hooks';
import { dynamicClient } from '<path to client file>';

const { wallets } = useReactiveClient(dynamicClient);
// wallets.primary -> primary wallet
// wallets.userWallets -> array of user wallets

useUserWallets

React Native provides access to all user wallets through the wallets.userWallets array from the reactive client.
React Native
import { useReactiveClient } from '@dynamic-labs/react-hooks';
import { dynamicClient } from '<path to client file>';

const { wallets } = useReactiveClient(dynamicClient);
const userWallets = wallets.userWallets;

return (
  <View>
    <Text>Wallets</Text>
    {userWallets.map((wallet) => (
      <Text key={wallet.id}>{wallet.address}</Text>
    ))}
  </View>
);

Check Which Wallet is Embedded

You can check which wallet is embedded by using the useUserWallets hook and looking for the isEmbeddedWallet boolean.
React Native
import { useReactiveClient } from '@dynamic-labs/react-hooks';
import { dynamicClient } from '<path to client file>';

const { wallets } = useReactiveClient(dynamicClient);
const userWallets = wallets.userWallets;

const embeddedWallet = userWallets.find(wallet => wallet.connector.isEmbeddedWallet);

onEmbeddedWalletCreated

React Native uses the client configuration to set up event handlers for embedded wallet creation.
React Native
// React Native uses the client configuration
const dynamicClient = createClient({
  environmentId: 'YOUR-ENVIRONMENT-ID',
  events: {
    onEmbeddedWalletCreated: (args) => {
      console.log('onEmbeddedWalletCreated was called', args);
    }
  }
});

Add extra logic during any wallet connection (walletConnected)

React Native uses the walletConnected event (equivalent to handleConnectedWallet in the React SDK) to add logic during wallet connection events.
React Native
const dynamicClient = createClient({
  environmentId: '<env id>',
});

dynamicClient.wallets.setHandler('walletConnected', (wallet) => {
  console.log("walletConnected was called", wallet);
  // if runYourOwnLogic return true, the connection will be established, otherwise it will not
  return runYourOwnLogic();
});

What next?

What next?

Continue with chain-specific guides (for example EVM).