# useChain | @account-kit/react

> Overview of the useChain hook from @account-kit/react

> For the complete documentation index, see [llms.txt](/docs/llms.txt).

{/* This file is auto-generated by TypeDoc. Do not edit manually. */}

```ts
function useChain(mutationArgs?): UseChainResult;
```

Defined in: [account-kit/react/src/hooks/useChain.ts:51](https://github.com/alchemyplatform/aa-sdk/blob/main/account-kit/react/src/hooks/useChain.ts#L51)

A [hook](https://github.com/alchemyplatform/aa-sdk/blob/main/account-kit/react/src/hooks/useChain.ts) that returns the current chain as well as a function to set the chain.
Note: when calling `setChain` the chain that's passed in must be defined in
your initial `createConfig` call. Calling `setChain` causes the chain to change across the board. For example, if you use set chain then use `useSmartAccountClient`, the client will flip to the loading state and address for the account on the changed chain.

For switching chains, you can also use [createBundlerClient](https://www.alchemy.com/docs/wallets/reference/aa-sdk/core/functions/createBundlerClient#createbundlerclient) or [createSmartAccoutClient](https://www.alchemy.com/docs/wallets/reference/aa-sdk/core/functions/createSmartAccountClient) directly and create a different client for each chain. You would have to manage different clients, but you wouldn't have to wait for any hooks to complete and can run these queries in parallel. This way the chain set in the config that the smart account client and other hooks inherit is not also affected.

## Example

```tsx twoslash
import React from "react";
import { useChain } from "@account-kit/react";
// Assuming the chain sepolia is defined in your initial createConfig call
import { sepolia } from "@account-kit/infra";

function ComponentUsingChain() {
  const { chain, setChain, isSettingChain } = useChain();

  return (
    <div>
      <p>Current Chain: {chain.id}</p>
      <button
        onClick={() => setChain({ chain: sepolia })}
        disabled={isSettingChain}
      >
        Set Chain
      </button>
    </div>
  );
}
```

## Parameters

<table>
  <thead>
    <tr>
      <th align="left">Parameter</th>
      <th align="left">Type</th>
      <th align="left">Description</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        `mutationArgs?`
      </td>

      <td>
        `Partial`\<`Omit`\<`UseMutationOptions`\<`void`, `Error`, \{ `chain`: [`Chain`](https://viem.sh); }, `unknown`>, `"mutationFn"` | `"mutationKey"`>>
      </td>

      <td>
        optional properties which contain mutation arg overrides. [ref](https://github.com/alchemyplatform/aa-sdk/blob/main/account-kit/react/src/hooks/useChain.ts#L14)
      </td>
    </tr>

  </tbody>
</table>

## Returns

[`UseChainResult`](../interfaces/UseChainResult)

an object containing the current chain and a function to set the chain as well as loading state of setting the chain. [ref](https://github.com/alchemyplatform/aa-sdk/blob/main/account-kit/react/src/hooks/useChain.ts#L16)