# useSolanaWallet

> @web3auth/modal React Hooks useSolanaWallet | Embedded Wallets

Hook to retrieve and manage Solana wallet, accounts, and connection from Web3Auth.

### Import

```tsx

```

### Usage

```tsx

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

  return (
    
      Accounts: {accounts ? accounts.join(', ') : 'No accounts'}
      SolanaWallet: {solanaWallet ? 'Available' : 'Not available'}
      Connection: {connection ? 'Connected' : 'Not connected'}
    
  )
}
```

### Return type

```tsx

```

#### `accounts`

`string[] | null`

The list of Solana account addresses, or null if not available.

#### `solanaWallet`

`SolanaWallet | null`

The SolanaWallet instance for interacting with the Solana blockchain, or null if not available.

#### `connection`

`Connection | null`

The Solana connection instance for making RPC calls, or null if not available.

### Example: fetching SOL balance

```tsx title="getBalance.tsx"

export function Balance() {
  const { accounts, connection } = useSolanaWallet()
  const [balance, setBalance] = useState<number | null>(null)
  const [isLoading, setIsLoading] = useState(false)
  const [error, setError] = useState<string | null>(null)

  const fetchBalance = async () => {
    if (connection && accounts && accounts.length > 0) {
      try {
        setIsLoading(true)
        setError(null)
        const publicKey = new PublicKey(accounts[0])
        const balance = await connection.getBalance(publicKey)
        setBalance(balance)
      } catch (err) {
        setError(err instanceof Error ? err.message : 'Unknown error')
      } finally {
        setIsLoading(false)
      }
    }
  }

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

  return (
    
      Balance
      {balance !== null && `${balance / LAMPORTS_PER_SOL} SOL`}
      {isLoading && Loading...}
      {error && Error: {error}}
      <button onClick={fetchBalance} type="submit" className="card">
        Fetch Balance
      </button>
    
  )
}
```
