switchNetwork
Action for switching networks with a connector.
import { switchNetwork } from '@wagmi/core'Usage
Some wallet apps do not support programmatic network switching and switchNetwork will throw an error, SwitchChainNotSupportedError. For those situations, you can typically switch networks in the wallet app and wagmi will stay up-to-date.
import { switchNetwork } from '@wagmi/core'
const network = await switchNetwork({
chainId: 1,
})Return Value
ChainConfiguration
chainId
Chain id to switch to.
import { switchNetwork } from '@wagmi/core'
const network = await switchNetwork({
chainId: 69,
})