@mysten/sui v2.0 and a new dApp Kit are here! Check out the migration guide
Mysten Labs SDKs
ReactHooks

useCurrentWallet

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;

On this page