Build a Custom UI
Use the SDK to connect wallets to your app but use your own UI either manually or using the useConnect
hook.
Create a Custom Connection
Connecting a wallet involves a few steps:
- Create a wallet instance
- Call the
connect
method on the wallet instance - Set the connected wallet instance as "connected wallet"
useConnect
If you just want to connect a wallet as mentioned above - there's a simple way to do it using the useConnect hook which does all the above steps for you.
Using useConnect
hook
Manually connect a wallet
If you need to create wallet instance and call some methods on the wallet instance before connecting the wallet, you can do these steps manually as shown below using the useCreateWalletInstance, useSetConnectionStatus and useSetConnectedWallet hooks.
Manually creating wallet instance and connecting
Once the wallet is connected, you can use React SDK's 100+ hooks to show the connected wallet's details, send transactions, interact with smart contracts, sign messages and utilize common standards such as tokens, NFTs, marketplaces; all with built-in caching, RPC URLs, IPFS gateways, and more!
The following hooks can be used with the connected wallet:
Hook | Description |
---|---|
useAddress | get connected wallet's account address |
useDisconnect | disconnect the connected wallet |
useWallet | get connected wallet instance |
useWalletConfig | get connected wallet's config |
useConnectionStatus | get status of wallet connection |
useSigner | get signer of connected wallet |
Create a Wallet Connection UI (in ConnectWallet)
Customize the UI of one of the supported wallets when using the ConnectWallet
component or add UI for a custom wallet configurator to add to the ConnectWallet
component.
connectUI
To create a custom UI for connecting your wallet, create a connectUI
function in your wallet configurator.
// optional - render a UI for connecting your wallet
connectUI(props) {
return <MyWalletConnectionUI {...props} />;
},
selectUI
To create a custom UI for selecting your wallet in the wallet selection screen in the connect wallet modal, create a selectUI
function in your wallet configurator.
// optional - override the default UI for selecting your wallet in the wallet selector screen
selectUI(props) {
return <MyWalletSelectionUI {...props} />
}