Appearance
useAllWalletBalances
Token balances for every connected wallet, grouped by walletId. Requires WalletsProvider.
isLoading stays true until balances and exchange rates are ready.
For one wallet, use useWalletBalances.
Example
tsx
import { useAllWalletBalances } from '@swapped/connect-sdk/react'
function AllBalances() {
const {
balances,
isLoading,
isRefetching,
isFetchingRates,
error,
refetch,
refetchForWallet,
} = useAllWalletBalances({
sort: 'balanceDesc',
enabled: true,
})
return (
<div>
{isLoading ? <p>Loading balances with rates…</p> : null}
{balances.map(group => (
<section key={group.walletId}>
{group.balances.map(token => (
<p key={`${token.symbol}-${token.network}-${token.tokenAddress}`}>
{token.formatted.balance} {token.symbol}
{token.formatted.fiatValue
? ` · $${token.formatted.fiatValue}`
: ''}
</p>
))}
</section>
))}
<button type="button" onClick={() => void refetch()}>
Refresh all
</button>
</div>
)
}Options
| Field | Meaning |
|---|---|
sort? | 'balanceDesc' — eligible first, then higher fiatValue |
enabled? | Skip fetching when false. Default true |
Returns
| Field | Meaning |
|---|---|
balances | WalletBalancesForWallet[] |
isLoading | Initial load until rates are ready (also true while restoring if enabled) |
isRefetching | refetch() in flight; previous rated balances stay on screen |
isFetchingRates | Fiat quotes in flight for the latest fetch |
error | Last fetch error |
refetch | Refresh every connected wallet |
refetchForWallet(walletId) | Refresh one instance |
WalletBalance fields: useWalletBalances and Balances (Core).