useWalletUiWallet
The useWalletUiWallet hook provides connect and disconnect functions for a specific wallet instance.
This hook is useful when you want to build a custom UI for a single wallet, for example, a dedicated “Connect to Phantom” button.
import { useWalletUiWallet, useWalletUiWallets } from '@wallet-ui/react';
function ConnectPhantom() { const { wallets } = useWalletUiWallets(); const phantomWallet = wallets.find(wallet => wallet.name === 'Phantom');
if (!phantomWallet) { return <p>Phantom wallet not found.</p>; }
return <ConnectWallet wallet={phantomWallet} />;}
function ConnectWallet({ wallet }) { const { connect, connecting } = useWalletUiWallet({ wallet });
return ( <button onClick={() => connect()} disabled={connecting}> {connecting ? 'Connecting...' : `Connect to ${wallet.name}`} </button> );}Return Value
Section titled “Return Value”The hook returns an object with the following properties:
| Name | Type | Description |
|---|---|---|
connect | () => Promise<void> | A function to connect to the specified wallet. |
connecting | boolean | A boolean indicating if the connection is in progress. |
disconnect | () => Promise<void> | A function to disconnect from the specified wallet. |
wallet | UiWallet | The wallet instance that the hook is interacting with. |