ReactHooks
useCurrentAccount
The useCurrentAccount hook provides access to the currently selected account.
All dApp Kit hooks must be used within components that are descendants of DAppKitProvider. Using them outside will result in an error.
Usage
import { useCurrentAccount } from '@mysten/dapp-kit-react';
export function MyComponent() {
const account = useCurrentAccount();
if (!account) {
return <div>No account selected</div>;
}
return (
<div>
<p>Address: {account.address}</p>
<p>Label: {account.label}</p>
</div>
);
}Return Value
UiWalletAccount | null;