> ## Documentation Index
> Fetch the complete documentation index at: https://docs.polygon.technology/llms.txt
> Use this file to discover all available pages before exploring further.

# useChain

> Hook to retrieve blockchain network configuration details by chain ID.

## Import

```tsx theme={null}
import { useChain } from '@0xsequence/connect'
```

## Usage

```tsx theme={null}
import { useChain } from '@0xsequence/connect'

function App() {
  // Get current chain configuration
  const currentChain = useChain()

  // Get configuration for a specific chain (e.g., Ethereum Mainnet)
  const ethereumChain = useChain(1)

  return (
    <div>
      <h2>Current Chain</h2>
      {currentChain && (
        <div>
          <p>Name: {currentChain.name}</p>
          <p>Chain ID: {currentChain.id}</p>
          <p>Network: {currentChain.network}</p>
          <p>Native Currency: {currentChain.nativeCurrency.symbol}</p>
        </div>
      )}

      <h2>Ethereum Mainnet</h2>
      {ethereumChain && (
        <div>
          <p>Name: {ethereumChain.name}</p>
          <p>Chain ID: {ethereumChain.id}</p>
          <p>Network: {ethereumChain.network}</p>
          <p>Native Currency: {ethereumChain.nativeCurrency.symbol}</p>
        </div>
      )}
    </div>
  )
}
```

## Parameters

| Parameter | Type                  | Description                                                                                                              |
| --------- | --------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| `chainId` | `number \| undefined` | Optional chain ID to get configuration for a specific chain. If not provided, returns the current chain's configuration. |

## Return Type: `Chain | undefined`

```tsx theme={null}
interface Chain {
  id: number
  name: string
  network: string
  nativeCurrency: {
    name: string
    symbol: string
    decimals: number
  }
  rpcUrls: {
    default: {
      http: string[]
      webSocket?: string[]
    }
    public: {
      http: string[]
      webSocket?: string[]
    }
  }
  blockExplorers?: {
    default: {
      name: string
      url: string
    }
  }
}
```

This hook relies on wagmi's chain configuration library. It is useful when you need to access details about the currently connected chain or retrieve configuration for a specific chain by ID.
