useChainId
Hook for retrieving the chain ID of the network the user is connected to.
import { useChainId } from "@thirdweb-dev/react";
Usage
import { useChainId } from "@thirdweb-dev/react";
function App() {
const chainId = useChainId();
return <div>{chainId}</div>;
}
Return value
number | undefined;
A number
representing the current chain id.
Returns undefined
if the chain id could not be found.