Skip to main content

useSwitchChain

Hook for switching to a different network.

import { useSwitchChain } from "@thirdweb-dev/react";

const switchChain = useSwitchChain();

Usage

import { useSwitchChain } from "@thirdweb-dev/react";
import { Goerli } from "@thirdweb-dev/chains";

function App() {
const switchChain = useSwitchChain();
return (
<button onClick={() => switchChain(Goerli.chainId)}>
Switch to Goerli
</button>
);
}