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:
Name | Type | Description |
---|---|---|
cluster | SolanaCluster | The currently selected Solana cluster object. |
clusters | SolanaCluster[] | An array of all available cluster objects. |
setCluster | (clusterId: SolanaClusterId) => void | A 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>
);
}