AvaCloud
UsageHooks

useChainId

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

If you need more help, explore our other articles or reach out to our support team via chat or email support@avacloud.io. All examples provided are for demonstration purposes only.

Learn More About AvaCloud | Download Case Studies | Schedule an AvaCloud Demo

On this page