Actions
Switch Account
The switchAccount action changes the currently selected account to a different account from the
connected wallet.
The "current account" is a dApp Kit concept that tracks which account is active within your application. Changing the active account in the dApp does not affect the wallet itself, and wallets are not notified when the active account changes.
Account switching is integrated into the Connect Button Web Component. When a wallet is connected with multiple accounts, the button provides an account selector.
Usage
import { createDAppKit } from '@mysten/dapp-kit-core';
const dAppKit = createDAppKit({
/* config */
});
// Switch to a different account
dAppKit.switchAccount({
account: anotherAccount, // UiWalletAccount from the connected wallet
});Parameters
account-UiWalletAccount- The account to switch to. Must be an account that belongs to the currently connected wallet.
Return Value
Returns void. The action completes synchronously and updates the connection state immediately.