Skip to content

WalletUiClusterContext

The WalletUiClusterContext provides information about the currently selected Solana cluster.

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.

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>
);
}