ReactHooks
useCurrentWallet
React hook to get the current wallet connection
The useCurrentWallet hook provides access to the currently connected wallet.
All dApp Kit hooks must be used within components that are descendants of DAppKitProvider. Using them outside will result in an error.
Usage
import { useCurrentWallet } from '@mysten/dapp-kit-react';
export function MyComponent() {
const wallet = useCurrentWallet();
if (!wallet) {
return <div>No wallet connected</div>;
}
return (
<div>
<p>Wallet: {wallet.name}</p>
<p>
Icon: <img src={wallet.icon} alt={wallet.name} />
</p>
<p>Accounts: {wallet.accounts.length}</p>
</div>
);
}Return Value
UiWallet | null;