useSwitchActiveWalletChain

Switch to blockchain with given chain id in the active wallet.

Example

import { useSwitchActiveWalletChain } from "thirdweb/react";
import { sepolia } from "thirdweb/chains";
const switchChain = useSwitchActiveWalletChain();
// later in your code
<button onClick={() => switchChain(sepolia)}>Switch Chain</button>;
function useSwitchActiveWalletChain(): (
chain: Readonly<ChainOptions & { rpc: string }>,
) => Promise<void>;

Returns

let returnType: (
chain: Readonly<ChainOptions & { rpc: string }>,
) => Promise<void>;

A function to switch to blockchain with given chain id in the active wallet.