HOOK use-markets
useMarkets
Discovers all active HIP-4 markets and subscribes to live mid prices via WebSocket. Returns { markets: Market[], mids: Record<string, string>, isLoading, error }. Feed markets to MarketCard and mids[coin] for yesMid. Stable markets array (useMemo) prevents downstream rerenders.
Install
$
npx shadcn@latest add https://ui.purrdict.xyz/r/use-markets.json Signature
useMarkets(client?: HIP4Client) Returns
{ markets, mids, isLoading, error } Usage
// Explicit client
const { markets, mids } = useMarkets(client)
// Or with HIP4Provider (no client needed)
const { markets, mids } = useMarkets() Dependencies
npm packages
Registry components