> ## Documentation Index
> Fetch the complete documentation index at: https://dynamic-docs-feat-sidebar-revamp.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Switching Networks

### Usage

Using the primaryWallet provided by [useDynamicContext](/react-sdk/hooks/usedynamiccontext),
you have two useful methods for network switching:

<ParamField path="supportsNetworkSwitching" type="() => boolean">
  Available on the connector object for the wallet.Whether the connector supports network switching.
</ParamField>

<ParamField path="switchNetwork" type="(networkChainId?: number | string) => Promise<void>">
  Available directly on the wallet object. Switch to another network by providing either the network name or chain id.
</ParamField>

When calling `switchNetwork` with a connector supporting network switching, the SDK will either request the user to confirm the network switch or add the network if it was not previously set.

### Example

```TypeScript
const { primaryWallet } = useDynamicContext();

if (primaryWallet?.connector.supportsNetworkSwitching()) {
  await primaryWallet.switchNetwork(137);
  console.log("Success! Network switched");
}
```

<Frame>
  ![1440](https://mintlify.s3.us-west-1.amazonaws.com/dynamic-docs-feat-sidebar-revamp/images/network-switching.png "Metamask network switching prompt")
</Frame>
