Connecting & Disconnecting
Manage wallet connection state and multi-wallet selection.
Search across all documentation pages
Manage wallet connection state and multi-wallet selection.
"use client";
import { useWallet } from "@solana/wallet-adapter-react";
const { connect, disconnect, connected, connecting, wallet, select } = useWallet();When to reach for this:
"use client";
import { useCallback } from "react";
import { useWallet } from "@solana/wallet-adapter-react";
import { useWalletModal } from "@solana/wallet-adapter-react-ui";
export function WalletControls() {
const { connected, disconnect, wallet } = useWallet();
const { setVisible } = useWalletModal();
const handleConnect = useCallback(() => setVisible(true), [setVisible]);
if (!connected) {
return <button onClick={handleConnect}>Select wallet</button>;
}
return (
<div>
<span>{wallet?.adapter.name}</span>
<button onClick={() => disconnect()}>Disconnect</button>
</div>
);
}What this demonstrates:
disconnect clears adapter session.| Alternative | Use When | Don't Use When |
|---|---|---|
| Embedded wallet (Phantom embedded) | Consumer onboarding | Full self-custody positioning |
| SIWS + server session | Web2-style login | Fully on-chain auth only |
Match RPC URL, wallet network, and program IDs to one cluster.
Use @solana/kit 7.0.0 for new frontend code.
Surfpool 0.12.0 or devnet with faucet SOL.
confirmed for UX; finalized for high-value reads.
Providers in client layout; reads can be server-side.
Show retry; never assume approval.
Compute budget instructions on congested mainnet.
Use Mobile Wallet Adapter for React Native apps.
Never expose server keypairs to the browser.
Regenerate typed clients in CI.
Stack versions: This page was written for Agave 4.1.1, Solana CLI 3.0.10, Anchor 0.32.1, anchor-lang 0.32.1, Rust 1.91.1, @solana/kit 7.0.0, Surfpool 0.12.0, and LiteSVM 0.6.x.
Reviewed by Chris St. John·Last updated Jul 16, 2026