Wallet Adapter
A Solana wallet connection button with a dialog wallet picker and connected-state dropdown.
Features
- Dialog-based wallet picker listing detected wallet adapters in the browser.
- Dropdown menu with truncated public key and disconnect action once connected.
- Loading state on the trigger button, and per-row, while a connection is in progress.
- Inline error message in the dialog if a connection attempt fails or is rejected.
- Safe handling of rapid wallet switching — only the most recently selected wallet's result is applied.
- Configurable Solana network and auto-connect behavior.
Installation
pnpm dlx shadcn@latest add https://www.harshalvk.com/r/wallet-adapter.json
Usage
import { WalletAdapter } from '@/components/wallet-adapter';<WalletAdapter />API Reference
WalletAdapter
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | Additional classes applied to the trigger button. |
Connection state is otherwise managed internally via the useWallet hook — connection status, the active public key, and the list of detected adapters all come from context.
WalletContextProvider
Wraps your application with Solana connection and wallet context.
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | — | Application content. |
network | Network | devnet | Solana cluster to connect to. |
autoConnect | boolean | true | Automatically reconnect to previously connected wallets. |
Notes
- Renders a
DialogTriggerbutton when no wallet is connected, opening a list of detected wallet adapters to choose from. - Once connected, swaps to a
DropdownMenushowing the truncated public key with a disconnect action. - Connection failures, including a user rejecting the request in their wallet extension, are shown as an inline message in the dialog.
WalletProvideris configured with an emptywalletsarray. Wallets that implement the Wallet Standard (Phantom, Solflare, Backpack, MetaMask, etc.) are auto-detected automatically — add adapters to that array only if you need to support a legacy, non-Wallet-Standard wallet.