Cosmos Kit
Hooks
Introduction

There are multiple hooks provided in CosmosKit. They all require ChainProvider from either @cosmos-kit/react or @cosmos-kit/react-lite to provide necessary information.

  • useChain: Provide chainWallet related properties and methods, and support multiple chains connected at one time. When useChain is called, corresponding chainWallets will be activated.

  • useChainWallet: Provide chainWallet related properties and methods, and support multiple chains and wallets connected at one time. When useChainWallet is called, corresponding chainWallet will be activated.

See more information about Differences Between useChain And useChainWallet

  • useManager: Manage all chains and wallets.

  • useModalTheme: Manage default modal themes.

  • useNameService: Get alias name of address from a particular name server.

  • useWallet: Manage all chainWallets and the global status for a particular wallet.

  • useWalletClient: Get the wallet client for a particular wallet.

  • useIframe: Set up an iframe that can access the currently connected wallet automatically.

Differences Between useChain And useChainWallet

  1. useChainWallet requires an extra parameter walletName.
  2. useChain will pop up a wallet modal to connect while useChainWallet not.
  3. useChain exposes extra openView and closeView methods and walletRepo property.
  4. the return value of methods getRpcEndpoint, getRestEndpoint, getStargateClient, getCosmWasmClient, getNameService can be different between useChain and useChainWallet, because useChain explores all chainWallets related to the parameter chainName.