> For the complete documentation index, see [llms.txt](/llms.txt).

# useSolanaWallet

Hook to retrieve Solana accounts, RPC client, and wallet from Web3Auth.

### Import[​](#import "Direct link to Import")

```
import { useSolanaWallet } from '@web3auth/modal/react/solana'

```

### Usage[​](#usage "Direct link to Usage")

```
import { useSolanaWallet } from '@web3auth/modal/react/solana'

function SolanaWalletInfo() {
  const { accounts, rpc, solanaWallet, getPrivateKey } = useSolanaWallet()

  return (
    <div>
      <div>Accounts: {accounts ? accounts.join(', ') : 'No accounts'}</div>
      <div>Solana wallet: {solanaWallet ? 'Available' : 'Not available'}</div>
      <div>RPC: {rpc ? 'Available' : 'Not available'}</div>
    </div>
  )
}

```

### Return type[​](#return-type "Direct link to Return type")

```
import { type IUseSolanaWallet } from '@web3auth/modal/react/solana'

```

#### `accounts`[​](#accounts "Direct link to accounts")

`string[] | null`

Base58 Solana account addresses, or `null` if not available.

#### `solanaWallet`[​](#solanawallet "Direct link to solanawallet")

`Wallet | null`

The wallet-standard Solana wallet instance, or `null` if not available.

#### `rpc`[​](#rpc "Direct link to rpc")

`Rpc<SolanaRpcApi> | null`

The `@solana/kit` RPC client for making Solana RPC calls, or `null` if not available.

#### `getPrivateKey`[​](#getprivatekey "Direct link to getprivatekey")

`() => Promise<string>`

Returns the user's private key when available (in-app adapters only).

### Example: Fetching SOL balance[​](#example-fetching-sol-balance "Direct link to Example: Fetching SOL balance")

getBalance.tsx

```
import { address } from '@solana/kit'
import { useSolanaWallet } from '@web3auth/modal/react/solana'
import { useEffect, useState } from 'react'

export function Balance() {
  const { accounts, rpc } = useSolanaWallet()
  const [balance, setBalance] = useState<number | null>(null)

  const fetchBalance = async () => {
    if (!rpc || !accounts?.length) return
    const { value } = await rpc.getBalance(address(accounts[0])).send()
    setBalance(Number(value) / 1e9)
  }

  useEffect(() => {
    fetchBalance()
  }, [rpc, accounts])

  return (
    <div>
      {balance !== null && <p>{balance} SOL</p>}
      <button onClick={fetchBalance} type="button">
        Fetch balance
      </button>
    </div>
  )
}

```
