React Hooks
Reference for B3 Global Accounts React hooks
B3 Global Accounts are deprecated. Upside and AnySpend now sign in with your own wallet. If you held funds in a Global Account and need help, ask in the B3 Discord. The team never DMs first and will never ask for your seed phrase or private key.
Account Hooks
useAccountWallet
Returns the wallet of the active account.
tsximport { useAccountWallet } from "@b3dotfun/sdk/global-account/react";function WalletAddress() { const { address, ensName } = useAccountWallet(); return <p>{ensName ?? address ?? "No wallet connected"}</p>;}
Return Values
| Property | Type | Description |
|---|---|---|
wallet | object | The active account, with address and ensName. Its meta.icon is always an empty string in 0.1.70 |
address | string | undefined | Address of the active account |
ensName | string | undefined | The B3 profile display name of that address, without .b3.fun. It is not an ENS lookup |
connectedSmartWallet | Wallet | undefined | The connected Global Account smart wallet |
connectedEOAWallet | Wallet | undefined | The connected external wallet |
isActiveSmartWallet | boolean | undefined | Whether the smart wallet is the active one |
isActiveEOAWallet | boolean | undefined | Whether the external wallet is the active one |
eoaWalletIcon | string | undefined | Always an empty string in 0.1.70 |
smartWalletIcon | string | undefined | Icon of the smart wallet |
Asset Management Hooks
useAccountAssets
useAccountAssets(address) returns a TanStack Query result whose data.nftResponse lists the NFTs that address holds. The query runs only when you pass an address.
tsximport { useAccountAssets, useAccountWallet } from "@b3dotfun/sdk/global-account/react";function AssetsComponent() { const { address } = useAccountWallet(); const { data, isLoading, error } = useAccountAssets(address); if (isLoading) return <div>Loading assets...</div>; if (error) return <div>Error loading assets: {error.message}</div>; return <pre>{JSON.stringify(data?.nftResponse, null, 2)}</pre>;}
Configuration Hooks
useB3Config
Returns the configuration passed to B3Provider.
tsximport { useB3Config } from "@b3dotfun/sdk/global-account/react";function ConfigComponent() { const { environment, partnerId } = useB3Config(); return ( <div> <p>Environment: {environment}</p> <p>Partner ID: {partnerId}</p> </div> );}
Return Values
| Property | Type | Description |
|---|---|---|
environment | "development" | "production" | The environment set on B3Provider |
partnerId | string | Your partner ID |
theme | "light" | "dark" | The theme set on B3Provider |
clientType | ClientType | The API client type |
authStrategy | AuthStrategy | The sign-in strategy |
It also returns accountOverride, automaticallySetFirstEoa, defaultPermissions, stripePublishableKey and createClientReferenceId. No other B3Provider prop is returned.
useB3
Deprecated. useB3 is an alias for useB3Config and returns the same configuration, not the signed-in account. Use useB3Config instead.