> ## 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.

# Getting Active Network

## Active Network id

The active network id is the id that the Dynamic SDK uses to identify the active network of a wallet account.

For EVM wallets, it will be the same as the chain id (e.g: 1, 137, 56, etc).
For other chains, it will an internal id used in Dynamic.

To get a more complete network data, you can use the `getActiveNetworkData` function mentioned further down in this page.

```javascript theme={"system"}
import { getActiveNetworkId } from '@dynamic-labs-sdk/client';

const { networkId } = await getActiveNetworkId({ walletAccount });
console.log(networkId);

```

## Active Network Data

The active Network Data is the data that the Dynamic SDK uses to identify the active network of a wallet account.

The NetworkData object contains useful information about the network, such as the id, name, icon, rpc urls, currency data, etc.

You can use the active network data create a [PublicClient](/javascript/reference/evm/getting-viem-public-client) for EVM accounts or a [Connection](/javascript/reference/solana/getting-solana-connection) for Solana accounts.

```javascript theme={"system"}
import { getActiveNetworkData } from '@dynamic-labs-sdk/client';

const { networkData } = await getActiveNetworkData({ walletAccount });
console.log(activeNetworkData);

```

## React

`useGetActiveNetworkData` automatically re-fetches whenever the wallet account changes or the user switches networks in their wallet.

```tsx theme={"system"}
import { type WalletAccount } from '@dynamic-labs-sdk/client';
import { useGetActiveNetworkData } from '@dynamic-labs-sdk/react-hooks';

function ActiveNetworkDisplay({ walletAccount }: { walletAccount: WalletAccount }) {
  const { data: activeNetwork } = useGetActiveNetworkData({ walletAccount });

  if (!activeNetwork?.networkData) return null;
  return <p>Active network: {activeNetwork.networkData.name}</p>;
}
```

## Related functions

* [Getting the Wallet Account Given an Address and Chain](/javascript/reference/wallets/get-wallet-account-from-address)
* [Switching Active Network](/javascript/reference/wallets/switch-active-network)
* [Getting Viem Public Client](/javascript/reference/evm/getting-viem-public-client)
* [Getting Solana Connection](/javascript/reference/solana/getting-solana-connection)
