# Switch chain

Switch the active chain for the user's embedded wallet.

:::info
When using *Smart accounts*, the address is at first pre-computed off-chain.
The account will be deployed when doing the first transaction with it.
Only [supported chains](/docs/configuration/chains) can be used with Smart Accounts.
:::

:::warning
ERC-7702 delegation must be **set per chain**.
When switching to a new chain, the delegation authorization needs to be re-established on that chain. See [EIP-7702 authorization](/docs/products/embedded-wallet/react/wallet/actions/eip-7702-authorization) for details.
:::

Use wagmi's `useSwitchChain` hook to change the active chain:

```tsx [SwitchChainButton.tsx]
import { useSwitchChain } from 'wagmi'
import { polygonAmoy, baseSepolia } from 'wagmi/chains'

function SwitchChainButton() {
  const { switchChain, isPending, error } = useSwitchChain()

  return (
    <div>
      <button
        onClick={() => switchChain({ chainId: polygonAmoy.id })}
        disabled={isPending}
      >
        {isPending ? 'Switching...' : 'Switch to Polygon Amoy'}
      </button>

      <button
        onClick={() => switchChain({ chainId: baseSepolia.id })}
        disabled={isPending}
      >
        {isPending ? 'Switching...' : 'Switch to Base Sepolia'}
      </button>

      {error && <p>Error: {error.message}</p>}
    </div>
  )
}
```
