@mysten/sui v2.0 and a new dApp Kit are here! Check out the migration guide
Mysten Labs SDKs
dApp Kit (Legacy)Wallet hooks

useAutoConnectWallet

Automatically reconnect to the last connected wallet

The useAutoConnectWallet hook retrieves the status for the initial wallet auto-connection process.

import { ConnectButton, useAutoConnectWallet } from '@mysten/dapp-kit';

function MyComponent() {
	const autoConnectionStatus = useAutoConnectWallet();

	return (
		<div>
			<ConnectButton />
			<div>Auto-connection status: {autoConnectionStatus}</div>
		</div>
	);
}

Example

Loading...

Auto-connection status properties

  • disabled - When the auto-connection functionality is disabled.
  • idle - When the initial auto-connection attempt hasn't been made yet.
  • attempted - When an auto-connection attempt has been made. This means either that there is no previously connected wallet, the previously connected wallet was not found, or that it has successfully connected to a wallet.

On this page