Skip to main content

Recommended: JavaScript SDK with React Hooks

For new React apps, we recommend the JavaScript SDK with React Hooks (@dynamic-labs-sdk/react-hooks) instead of the legacy React SDK documented here. The JS SDK comes with many benefits such as a much smaller bundle size and other optimizations. Use the React quickstart (JavaScript SDK) to get started.

Summary

Fetches the private (shielded) token balances held by the primary wallet, for chains that distinguish a public balance from a private one. Today the only such chain in the SDK is Aleo; on every other chain the hook returns an empty list with supportsPrivateBalances: false, so application code can call it unconditionally alongside useTokenBalances. The return shape mirrors useTokenBalances with an added supportsPrivateBalances discriminator, so the two hooks can be composed with minimal call-site changes.
On Aleo, private balances are derived from owned records (“UTXOs”) fetched through the wallet iframe. The view key never leaves the iframe.

Usage

Return value

Refreshing after a transaction

On Aleo the SDK applies an optimistic update to both the public and private balances the moment shieldToken resolves, so the UI reacts immediately without waiting for the indexer to surface the new record. A subsequent refetch() reconciles with the server once the record is indexed.

Composing with useTokenBalances

Application code can call both hooks unconditionally and let the chain support flags decide which sections to render:

See also

  • Using Aleo wallets — the broader Aleo guide, including the underlying listOwnedRecords, shieldToken, and proveTransaction primitives.
  • useTokenBalances — public token balances on chains where Dynamic supports them.
  • Token Balances reference — caching, rate limiting, and supported chains for public balances.
Last modified on June 25, 2026