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

# Network management

> The React SDK rendered the network picker and the 'switch in your wallet' modal for you. In the JavaScript SDK you read the network data and drive switching yourself.

The React SDK gave you `useSwitchNetwork()` and, when a wallet couldn't switch programmatically, automatically opened a "switch in your wallet" modal. It also exposed the configured networks through a hook. The JavaScript SDK exposes the same data and actions as functions (and matching React hooks) and leaves the UI — including the manual-switch prompt — to you.

## What maps to what

| React SDK                                       | JavaScript SDK                                                                   |
| ----------------------------------------------- | -------------------------------------------------------------------------------- |
| `wallet.getNetwork()`                           | `getActiveNetworkData({ walletAccount })`                                        |
| `useNetworkConfigurationsFromProjectSettings()` | `getNetworksData()`                                                              |
| `useSwitchNetwork()`                            | `switchActiveNetwork({ networkId, walletAccount })` / `useSwitchActiveNetwork()` |
| `connector.supportsNetworkSwitching()`          | `isProgrammaticNetworkSwitchAvailable({ walletAccount })`                        |
| auto `network-not-supported-manual` modal       | you build the manual-switch prompt                                               |

## Reading the active network

`getActiveNetworkData({ walletAccount })` returns `{ networkData }` for the wallet's current network (`displayName`, `iconUrl`, `nativeCurrency`, `networkId`), per the `WalletAccount` your app supplies. `getNetworksData()` returns every network enabled for your project. The React hook `useGetActiveNetworkData` refetches on the `networkChanged` event, so your UI stays correct even when the user switches networks from inside their wallet — the behavior the widget used to give you automatically.

## Switching networks

`useSwitchNetwork()` becomes `switchActiveNetwork({ networkId, walletAccount })` (or the `useSwitchActiveNetwork()` mutation). The one migration difference that matters: the React SDK silently opened a `network-not-supported-manual` modal when the wallet couldn't switch on its own. The JavaScript SDK throws `NetworkSwitchingUnavailableError` instead, so you check `isProgrammaticNetworkSwitchAvailable({ walletAccount })` first — call `switchActiveNetwork()` when it's `true`, and render your own "switch in your wallet" prompt (showing the target network's `displayName`) when it's `false`, confirming the result with `getActiveNetworkData()`.

<Tip>
  Validate the network right before you send a transaction, not just on page load — a user can switch networks in their wallet at any time.
</Tip>

## Building it

The picker, the validate-before-an-action guard, and error handling are the same build in any JavaScript SDK app, so they aren't duplicated here. [**Network switching & validation** (Building UI)](/docs/javascript/building-ui/network-switching) walks through them end to end:

* [Showing the active network](/docs/javascript/building-ui/network-switching#showing-the-active-network) — render the enabled networks from `getNetworksData()`, mark the active one from `getActiveNetworkData()`, and re-read after each switch.
* [Validating before an action](/docs/javascript/building-ui/network-switching#validating-before-an-action) — the "wrong network" guard that drives a programmatic or manual switch before letting a transaction proceed.
* [Handling errors](/docs/javascript/building-ui/network-switching#handling-errors) — `NetworkSwitchingUnavailableError`, a rejected switch, an unconfigured target network, and `undefined` network data.

## See also

* [Using connected wallets](/docs/javascript/migrating-from-react/using-connected-wallets) — the wallet you switch networks for
* [Network switching & validation (Building UI)](/docs/javascript/building-ui/network-switching) — build the full picker and guard
* Transactions & balance — validate the network right before sending
