Overview
This guide will walk you through integrating Hermis into a React application. You’ll learn how to set up wallet connections, display wallet information, and perform basic Solana operations.Installation
Install the React package and its peer dependencies:Step 1: Set Up the Provider
Wrap your app with theHermisProvider to enable wallet functionality throughout your application:
App.tsx
Provider Options
The Solana RPC endpoint URL (e.g.,
https://api.devnet.solana.com)The Solana network:
Mainnet, Devnet, or TestnetAutomatically reconnect to the last used wallet on page load
Array of wallet adapters to support
Callback function for handling wallet errors
Step 2: Create a Wallet Component
Use theuseWallet hook to access wallet functionality:
Home.tsx
Step 3: Send a Transaction
Add transaction functionality using thesendTransaction method:
Available Hooks
useWallet
Primary hook for wallet interactions:useConnection
Access the Solana connection:useSolanaBalance
Fetch and track wallet balance:useSolanaTokenAccounts
Fetch SPL token accounts:useSolanaNFTs
Fetch NFTs owned by a wallet:useSolanaTransaction
Track transaction status with confirmations:useWalletAdapters
Get grouped and sorted wallet adapters:useAnchorWallet
Get an Anchor-compatible wallet with dual architecture support:useWalletModal
Manage wallet selection modal state:Next.js Integration
For Next.js 13+ with App Router, create a client-side provider:app/providers.tsx
app/layout.tsx
Best Practices
Handle Connection States
Handle Connection States
Always check
connecting, connected, and disconnecting states to provide appropriate UI feedback to users.Error Handling
Error Handling
Implement proper error handling for all wallet operations, especially during transactions. Use the
onError callback in the provider.Mobile Wallet Adapter Performance
Mobile Wallet Adapter Performance
For best performance with Solana Mobile Wallet Adapter, disable battery/power saving mode on your device. Power saving modes can interfere with wallet adapter connections, transaction signing, and deeplinking to wallet applications.Disabling power saving mode ensures:
- Reliable wallet adapter connections
- Smooth deeplinking between your dApp and wallet apps
- Faster transaction signing responses
Network Selection
Network Selection
Ensure your RPC endpoint matches the intended network. Don’t mix mainnet and devnet operations.
What’s Next?
API Reference
Explore the complete React API documentation
Cookbook
Learn practical patterns and examples
Send Transactions
Learn how to send SOL and tokens
Sign Messages
Implement message signing
