Registry / payments / react-native-format-currency

react-native-format-currency

JSON →
library1.0.0jsnpmunverified

A lightweight, zero-dependency currency formatter for React Native and Expo built with TypeScript. It supports 165+ ISO 4217 currency codes and provides correct symbol placement, thousands/decimal separators, and negative amount formatting. The library returns both symbol-prefixed and plain values as an array or object. Caching via an internal LRU cache (max 100 entries) ensures fast repeated calls. Unlike locale-based formatters, this uses pre-defined rules for each currency. Stable v1.0.0 — released with minimal breaking changes expected.

npm install react-native-format-currency
INSTALL
IMPORT
SIG · REACT-NATIVE-FORMA
R
react-native-format-currency
paymentsjavascriptv1.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

formatCurrency
import { formatCurrency } from 'react-native-format-currency'
import formatCurrency from 'react-native-format-currency'
Default export does not exist; use named import.
getSupportedCurrencies
import { getSupportedCurrencies } from 'react-native-format-currency'
const getSupportedCurrencies = require('react-native-format-currency').getSupportedCurrencies
ESM import is preferred; require works but is less common for TypeScript.
CURRENCIES
import { CURRENCIES } from 'react-native-format-currency'
CURRENCIES is a named export containing full currency configurations.

Shows basic usage of formatCurrency with array and object return types, and how to list supported currencies.

import { formatCurrency, getSupportedCurrencies } from 'react-native-format-currency'; const [withSymbol, withoutSymbol, symbol] = formatCurrency({ amount: 1234.56, code: 'USD', }); console.log(withSymbol); // '$1,234.56' // Object return type const result = formatCurrency({ amount: 1234.56, code: 'USD', returnType: 'object' }); // { formatted: '$1,234.56', value: '1,234.56', symbol: '$' } // List all supported currencies const currencies = getSupportedCurrencies(); console.log(currencies.length); // 165+
Debug
Known issues
gotchaformatCurrency does not accept a locale argument; formatting is based solely on internal currency rules (symbol, separators, etc.) and may not match user's locale expectations.
fix
If locale-aware formatting is needed, consider using Intl.NumberFormat instead.
affects: >=1.0.0
gotchaAmounts are passed as numbers; floating-point rounding may occur. For precise formatting (e.g., cents), pass an integer and divide/round prior.
fix
Use integers for cents (e.g., 123456 for $1,234.56) and multiply/divide accordingly before formatting.
affects: >=1.0.0
deprecatedreturnType: 'array' is the default but can be explicitly set; use 'object' for readability.
fix
Set returnType to 'object' if you prefer destructuring named properties.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'react-native-format-currency' or its corresponding type declarations.
Package not installed or TypeScript cannot resolve the module path.
fix
Run 'npm install react-native-format-currency' (or yarn/pnpm) and ensure tsconfig.json includes 'node_modules' in moduleResolution.
Property 'formatCurrency' does not exist on type 'typeof import("react-native-format-currency")'.
Using default import instead of named import.
fix
Change 'import f from ...' to 'import { formatCurrency } from ...'
Expected 0 arguments, but got 1.
A caller used formatCurrency(amount, code) as separate arguments instead of an options object.
fix
Use formatCurrency({ amount: 1234.56, code: 'USD' })
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
29 hits · last 30 days
node
27
Resources
react-native-format-currency — npm install react-native-format-currency · libregistry