Hook for accessing the chain ID of the network the current wallet is connected to
import { useChainId } from "@thirdweb-dev/react";
import { useChainId } from "@thirdweb-dev/react"; const App = () => { const chainId = useChainId(); return <div>{chainId}</div>;};
function useChainId(): number | undefined;
let returnType: number | undefined;
A number representing the current chain id, or undefined if the user is not connected to a wallet.
number
undefined
For Example, if the user is connected to the Ethereum Mainnet, the return value will be 1 .
1