Wallet Integration
This guide explains how to integrate Solana wallets into your Next.js application using wallet adapters.Overview
The template uses the official Solana wallet adapter libraries:@solana/wallet-adapter-react- React hooks and context@solana/wallet-adapter-react-ui- Pre-built UI components@solana/wallet-adapter-wallets- Wallet implementations
Wallet Provider Setup
Createwallet/provider.tsx:
Key Concepts
ConnectionProvider
Provides the Solana connection to all child components:WalletProvider
Manages wallet state and provides hooks:wallets- Array of wallet adapters to supportautoConnect- Automatically reconnect on page load
WalletModalProvider
Provides the wallet selection modal:Using Wallet Hooks
useWallet
Access wallet state and methods:useConnection
Access the Solana connection:useAnchorWallet
Get a wallet compatible with Anchor:useWalletModal
Control the wallet selection modal:Header Component with Wallet
Here’s the complete header component with wallet connection:Supported Wallets
The template supports these wallets out of the box:| Wallet | Adapter |
|---|---|
| Phantom | PhantomWalletAdapter |
| Solflare | SolflareWalletAdapter |
| Ledger | LedgerWalletAdapter |