useNetworkSwitcherModal

Hook to open the Wallet Network Switcher Modal that shows allows users to switch to different network.

Example

import { createThirdwebClient } from "thirdweb";
import { useNetworkSwitcherModal } from "thirdweb/react";
import { base, ethereum, polygon, sepolia, arbitrum } from "thirdweb/chains";
const client = createThirdwebClient({
clientId: "<your_client_id>",
});
function Example() {
const networkSwitcher = useNetworkSwitcherModal();
function handleClick() {
networkSwitcher.open({
client,
theme: 'light'
sections: [
{ label: 'Recently used', chains: [arbitrum, polygon] },
{ label: 'Popular', chains: [base, ethereum, sepolia] },
]
});
}
return <button onClick={handleClick}> Switch Network </button>
}

Returns