AvaCloud API
AvaCloud App
AvaCloud Wallet as a Service
AvaCloud Wallet as a Service
  • AvaCloud Wallet as a Service SDK
  • 🚀Getting Started
    • Quickstart
  • ⚙️USAGE
    • 🪝Hooks
      • useAvaCloudWallet
      • useAuth
      • useSignMessage
      • useSignTransaction
      • useTransferTokens
      • useUserWallets
      • useChainId
    • UI Components
      • LoginButton
      • WalletButton
      • WalletDisplay
      • UserProfile
      • WalletCard
      • TokensView
      • SendView
      • ReceiveView
      • ExportView
    • 🛠️Advanced Usage
Powered by GitBook

© 2025 Ava Labs, Inc.

On this page

Was this helpful?

  1. USAGE
  2. Hooks

useChainId

Hook for accessing and setting the current chain ID.

import { useChainId } from '@avalabs/avacloud-waas-react';

function ChainSelector() {
  const { chainId, setChainId } = useChainId();

  return (
    <div>
      <p>Current Chain ID: {chainId}</p>
      <button onClick={() => setChainId(43114)}>
        Switch to Mainnet
      </button>
    </div>
  );
}

Returns

  • chainId: number - Current chain ID

  • setChainId: (chainId: number) => void - Function to update the chain ID

PrevioususeUserWalletsNextUI Components

Last updated 28 days ago

Was this helpful?

⚙️
🪝