Skip to main content

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 the HermisProvider to enable wallet functionality throughout your application:
App.tsx

Provider Options

string
required
The Solana RPC endpoint URL (e.g., https://api.devnet.solana.com)
WalletAdapterNetwork
required
The Solana network: Mainnet, Devnet, or Testnet
boolean
default:"false"
Automatically reconnect to the last used wallet on page load
Adapter[]
Array of wallet adapters to support
(error: Error) => void
Callback function for handling wallet errors

Step 2: Create a Wallet Component

Use the useWallet hook to access wallet functionality:
Home.tsx

Step 3: Send a Transaction

Add transaction functionality using the sendTransaction 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
Then use in your layout:
app/layout.tsx

Best Practices

Always check connecting, connected, and disconnecting states to provide appropriate UI feedback to users.
Implement proper error handling for all wallet operations, especially during transactions. Use the onError callback in the provider.
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
Tip: Instruct users to disable power saving mode before connecting their mobile wallet for optimal experience.
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