Components

Wallet Adapter

A Solana wallet connection button with a dialog wallet picker and connected-state dropdown.

Loading…

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

PropTypeDefaultDescription
classNamestringAdditional 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.

PropTypeDefaultDescription
childrenReactNodeApplication content.
networkNetworkdevnetSolana cluster to connect to.
autoConnectbooleantrueAutomatically reconnect to previously connected wallets.

Notes

  • Renders a DialogTrigger button when no wallet is connected, opening a list of detected wallet adapters to choose from.
  • Once connected, swaps to a DropdownMenu showing 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.
  • WalletProvider is configured with an empty wallets array. 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.