Skip to main content
React Native provides the ability to switch the user’s primary wallet through the wallets.setPrimary() method on the dynamic client. You can access the current primary wallet and switch to a different one using the reactive client:
React Native
import { FC } from 'react';
import { dynamicClient } from '<path to client file>';
import { useReactiveClient } from '@dynamic-labs/react-hooks';
import { View, Text, TouchableOpacity } from 'react-native';

const SetFirstWalletRN: FC = () => {
  const { wallets } = useReactiveClient(dynamicClient);

  return (
    <View>
      <Text>Current primary wallet: {wallets.primary?.address}</Text>

      <TouchableOpacity
        onPress={() => wallets.setPrimary({ walletId: wallets.userWallets[0].id })}
      >
        <Text>Set first wallet as primary</Text>
      </TouchableOpacity>
    </View>
  );
};