Overview
The React package provides a custom wallet provider that wraps Solana’s wallet adapter with Drift-specific functionality, including:- Custom autoconnect logic
- Mobile wallet adapter support (SAGA)
- Wallet state synchronization with Drift store
- Persistent wallet selection
Setting Up Wallets
Using Default Wallet Providers
The package exports a default list of wallet adapters:- Phantom
- Solflare
- Coinbase Wallet
- Math Wallet
- Coin98
- Clover
Custom Wallet Configuration
You can provide your own wallet adapters:Using the Wallet Hook
Access wallet state and methods with theuseWalletContext hook:
Wallet Context State
TheuseWalletContext hook returns:
Wallet Selection UI
Create a wallet selection modal:Autoconnect Configuration
Disabling Autoconnect
Custom Autoconnect Delay
By default, autoconnect waits 4 seconds. You can customize this:Mobile Wallet Adapter (SAGA)
The wallet provider automatically detects and prioritizes the Mobile Wallet Adapter on SAGA devices:/home/daytona/workspace/source/react/src/providers/DriftWalletProvider.tsx:228-244
Accessing Wallet Authority
The connected wallet’s public key is stored in the Drift store:SOL Balance Tracking
The wallet’s SOL balance is automatically tracked:/home/daytona/workspace/source/react/src/hooks/useSolBalance.tsx:1-80
Signing Transactions
Sign and send transactions using the wallet context:Best Practices
- Check Connection State: Always check
wallet.connectedbefore attempting wallet operations - Handle Errors: Wrap wallet operations in try-catch blocks
- User Feedback: Show loading states during connection/disconnection
- Persistent Selection: The provider automatically remembers the last connected wallet
- Mobile Support: Test on SAGA devices to ensure Mobile Wallet Adapter works correctly
Next Steps
Drift Provider Setup
Learn how to configure the DriftProvider and its hooks