/** * Configuration options for the useCurrencyLocalizer hook */ export interface UseCurrencyLocalizerOptions { /** The three-letter ISO 4217 code of the base currency (e.g., 'USD') */ baseCurrency: string; /** The API key obtained from exchangerate-api.com for fetching rates */ apiKey: string; /** A three-letter ISO 4217 code to manually specify the target currency, bypassing IP geolocation */ manualCurrency?: string; /** Custom geolocation endpoint URL (defaults to ipapi.co) */ geoEndpoint?: string; /** An optional callback function that fires when ready */ onReady?: (localCurrency: string) => void; /** An optional callback function that fires upon failure */ onError?: (error: Error) => void; } /** * Result object returned by the useCurrencyLocalizer hook */ export interface CurrencyLocalizerResult { /** Convert a price from base currency to local currency */ convert: (price: number) => number | null; /** Format a price in the local currency using Intl.NumberFormat */ format: (price: number) => string; /** Convert and format in one call */ convertAndFormat: (price: number) => string; /** The detected or manually set local currency code. null during loading */ localCurrency: string | null; /** The base currency code that was provided as input */ baseCurrency: string; /** The fetched exchange rate. null during loading or on error */ exchangeRate: number | null; /** True while either the geolocation or exchange rate data is being fetched */ isLoading: boolean; /** True when the converter is ready to use */ isReady: boolean; /** An Error object if one occurred, null otherwise */ error: Error | null; } /** * A batch-friendly hook for currency conversion that provides converter functions. * * Unlike useCurrencyConverter which is designed for single price conversion, * this hook provides convert() and format() functions that can be called * multiple times without additional API calls. * * @example * ```tsx * const { convert, format, convertAndFormat, isReady } = useCurrencyLocalizer({ * baseCurrency: 'USD', * apiKey: 'your-api-key', * }) * * // Convert multiple prices efficiently * const prices = [9.99, 19.99, 29.99].map(convertAndFormat) * ``` */ export declare const useCurrencyLocalizer: ({ baseCurrency, apiKey, manualCurrency, geoEndpoint, onReady, onError, }: UseCurrencyLocalizerOptions) => CurrencyLocalizerResult; //# sourceMappingURL=useCurrencyLocalizer.d.ts.map