Skip to content

useChainId

Hook for getting current chain ID.

Import

import { useChainId } from "starkweb/react"

Usage

index.tsx
import { useChainId } from "starkweb/react"
 
function App() {
  const chainId = useChainId()
}

Parameters

import { type UseChainIdParameters } from "starkweb/react"

config

Config | undefined

Config to use instead of retrieving from the nearest StarkwebProvider.

index.tsx
import { useChainId } from "starkweb/react"
import { config } from "./config"
 
function App() {
  const chainId = useChainId({
    config, 
  })
}

Return Type

import { type UseChainIdReturnType } from "starkweb/react"

number

Current chain ID from config.state.chainId.

Actions