Wallet UI LogoWallet UI

WalletUiClusterContext

The context for the currently selected Solana cluster.

The WalletUiClusterContext provides information about the currently selected Solana cluster.

WalletUiClusterContextValue

The context provides an object with the following properties:

NameTypeDescription
clusterSolanaClusterThe currently selected Solana cluster object.
clustersSolanaCluster[]An array of all available cluster objects.
setCluster(clusterId: SolanaClusterId) => voidA function to set the active cluster by its ID.

Example

This example shows how you could use the context to get the current cluster.

import { useContext } from 'react';
import { WalletUiClusterContext } from '@wallet-ui/react';

function ClusterDetails() {
    const { cluster } = useContext(WalletUiClusterContext);

    return (
        <div>
            <p>Current Cluster: {cluster.label}</p>
        </div>
    );
}