Docs

useSwitchChain

Hook for switching to a different network.

Example

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>
);
}

Returns

A function to switch the network in the currently connected wallet to network with given chainId