VisorVisor
Hooks

useCurrency

Detects the user's locale and returns the appropriate currency, symbol, and price formatter.

Usage

const { currency, symbol, formatPrice } = useCurrency()
const label = formatPrice({ usd: 99, eur: 89, gbp: 79 }) // "$99"

Installation

npx visor add use-currency

Parameters

This hook takes no parameters.

Returns

NameTypeDescription
currency'usd' | 'eur' | 'gbp'Detected currency code based on browser locale.
symbolstringCurrency symbol ($, EUR, or GBP).
formatPrice(prices: Record<Currency, number>) => stringFormats a price object into a localized string using the detected currency.