> For the complete documentation index, see [llms.txt](https://docs.baas.sh/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.baas.sh/baas-sdk/blockchain/networks.md).

# Networks

List your project's supported networks and pick the active one, for passkey or external-wallet sessions.

The `baas.chains` namespace lets your users pick which network (EVM chain) is active, for both passkey and external-wallet sessions. The list comes from your project's [Wallet Settings](/baas-console/wallet-settings.md): the chains enabled for the kind of wallet the user signed in with, so a passkey session and an external-wallet session of the same project may not see the same chains.

{% hint style="info" %}
`baas.chains` lists and switches the chains your project exposes. It does not connect wallets — use wagmi or RainbowKit for that.
{% endhint %}

## List the available networks

Read the chains this session may use.

```ts
const chains = await baas.chains.list();
// → [{ label: 'Base', chainId: 8453, rpcUrl: '…', isMainnet: true,
//      nativeCurrencySymbol: 'ETH', isBaaSChain: false }, …]
```

`isBaaSChain` identifies the project's own BaaS chain; external networks have `isBaaSChain: false`. It does not indicate whether the RPC is public or protected.

## Switch the active network

Set the chain the next operations run on.

```ts
await baas.chains.switch(10);                              // passkey — headless, no prompt
await baas.chains.switch(10, { signer: window.ethereum }); // wallet — native confirmation
```

A wallet session drives the wallet, which asks the user to confirm; a passkey session switches headlessly.

## React to a network change

Subscribe to keep your UI on the current chain.

```ts
const unsubscribe = baas.chains.onChainChange((chainId) => {
  // chainId is `number | null`
});
```

The callback fires immediately, then on every change: a `switch()` or a manual switch in the user's wallet.

## The active chain

While `active()` is `null`, a new chain-aware operation throws `CHAIN_SELECTION_REQUIRED`.

For a passkey session the choice survives a reload and ends with the session.

{% hint style="info" %}
A passkey session's active chain is a client-side choice. Enforce chain rules on your BaaS API, not in the browser.
{% endhint %}

## Follow the wallet's network after a reload

With an external wallet, `active()` follows the network the user selects in their wallet, so your UI reflects their current chain. That live sync starts at sign-in, and a page reload clears it. Bring it back with one call at boot:

```ts
await baas.chains.watchWallet(window.ethereum); // the provider you signed in with
```

Now `active()` and `onChainChange` follow the wallet again, with no prompt. Pass the provider the user signed in with. Passkey sessions don't need this.

In React, call it from a top-level effect. See [Use with React](/baas-sdk/integrations/react.md).

## Next

* [External wallet](/baas-sdk/authentication/external-wallet.md) — sign in with MetaMask or any EIP-1193 wallet.
* [API reference](/baas-sdk/resources/api-reference.md) — the `BaasChain` type and full method signatures.
* [Error handling](/baas-sdk/resources/error-handling.md) — `UNKNOWN_CHAIN` and network errors from `list()` / `switch()`.
