Skip to main content
The useAccount hook provides access to the current user’s account state, including both embedded Para accounts and connected external wallets across EVM, Cosmos, and Solana chains.

Import

import { useAccount } from "@getpara/react-sdk@alpha";

Usage

function AccountInfo() {
  const account = useAccount();

  if (account.isLoading) return <div>Loading account...</div>;

  if (!account.isConnected) {
    return <div>Not connected</div>;
  }

  return (
    <div>
      <h3>Connection Type: {account.connectionType}</h3>
      
      {account.embedded.isConnected && (
        <div>
          <h4>Embedded Account</h4>
          <p>User ID: {account.embedded.userId}</p>
          <p>Auth Type: {account.embedded.authType}</p>
          <p>Email: {account.embedded.email}</p>
          <p>Wallets: {account.embedded.wallets?.length || 0}</p>
        </div>
      )}
      
      {account.external.connectedNetworks.length > 0 && (
        <div>
          <h4>External Wallets</h4>
          <p>Connected Networks: {account.external.connectedNetworks.join(', ')}</p>
          {account.external.evm.isConnected && (
            <p>EVM Address: {account.external.evm.address}</p>
          )}
          {account.external.cosmos.isConnected && (
            <p>Cosmos Connected</p>
          )}
          {account.external.solana.isConnected && (
            <p>Solana Public Key: {account.external.solana.publicKey?.toString()}</p>
          )}
        </div>
      )}
    </div>
  );
}

Return Value Structure

The hook returns a UseAccountReturn object with the following properties:

Top-Level Properties

  • isConnected: boolean - Whether there is a wallet connected (either embedded, external or both)
  • isLoading: boolean - Whether the account is currently loading
  • connectionType: 'embedded' | 'external' | 'both' | 'none' - The type of connection for the account
    • 'embedded' - Only the embedded account is connected
    • 'external' - Only an external wallet is connected
    • 'both' - Both embedded and external wallets are connected
    • 'none' - No wallets are connected

Embedded Account Properties

embedded object contains:
  • isConnected: boolean - Whether the embedded Para account is connected
  • isGuestMode?: boolean - Whether the user is in guest mode
  • userId?: string - Unique identifier for the user
  • authType?: 'email' | 'phone' | 'farcaster' | 'telegram' | 'externalWallet' - Authentication method used
  • email?: string - User’s email address (only if authType is ‘email’)
  • phone?: string - User’s phone number (only if authType is ‘phone’)
  • farcasterUsername?: string - Farcaster username (only if authType is ‘farcaster’)
  • telegramUserId?: string - Telegram user ID (only if authType is ‘telegram’)
  • externalWalletAddress?: string - External wallet address (only if authType is ‘externalWallet’)
  • wallets?: Array<Wallet> - Array of available wallets for the user

External Wallet Properties

external object contains:
  • connectedNetworks: Array<'evm' | 'cosmos' | 'solana'> - List of connected external networks
  • evm - EVM wallet connection data (if connected)
    • isConnected: boolean
    • address?: string
    • addresses?: string[]
    • chain?: Chain
    • chainId?: number
    • status: 'connected' | 'reconnecting' | 'connecting' | 'disconnected'
  • cosmos - Cosmos wallet connection data (if connected)
    • isConnected: boolean
    • Additional Cosmos-specific properties
  • solana - Solana wallet adapter data (if connected)
    • isConnected: boolean
    • isConnecting?: boolean
    • publicKey?: PublicKey
    • name?: string
    • icon?: string

Examples

Basic Connection Check

function ConnectionStatus() {
  const { isConnected, connectionType } = useAccount();
  
  return (
    <div>
      <p>Connected: {isConnected ? 'Yes' : 'No'}</p>
      <p>Connection Type: {connectionType}</p>
    </div>
  );
}

Accessing Embedded Wallet Address

function WalletAddress() {
  const account = useAccount();
  
  if (!account.isConnected || !account.embedded.wallets?.length) {
    return <div>No wallet connected</div>;
  }
  
  return (
    <div>
      <p>Address: {account.embedded.wallets[0].address}</p>
    </div>
  );
}

Working with External Wallets

function ExternalWalletInfo() {
  const { external } = useAccount();
  
  return (
    <div>
      {external.evm.isConnected && (
        <p>EVM Address: {external.evm.address}</p>
      )}
      {external.cosmos.isConnected && (
        <p>Cosmos wallet connected</p>
      )}
      {external.solana.isConnected && (
        <p>Solana: {external.solana.name}</p>
      )}
    </div>
  );
}

Complete Connect Wallet Component

function ConnectWallet() {
  const { openConnectModal, openWalletModal } = useModal();
  const account = useAccount();
  
  if (account.isConnected && account.embedded.wallets?.length) {
    return (
      <button
        onClick={openWalletModal}
        className="px-4 py-2 bg-blue-500 text-white rounded"
      >
        {account.embedded.wallets[0].address.slice(0, 6)}...{account.embedded.wallets[0].address.slice(-4)}
      </button>
    );
  }
  
  return (
    <button
      onClick={openConnectModal}
      className="px-4 py-2 bg-green-500 text-white rounded"
    >
      Connect Wallet
    </button>
  );
}

Notes

  • The hook automatically refetches when the user’s authentication state changes
  • Use isLoading to show loading states while fetching account data
  • The embedded account refers to Para’s native wallet system
  • External wallets are third-party wallets connected via standard wallet connectors
  • When both embedded and external wallets are connected, connectionType will be 'both'
I