react-usekit

Beta

formatCurrency

Format a number as currency with locale support.

Installation

npx react-usekit@latest init

Select: utils → TypeScript or JavaScript → path -> formatCurrency

Usage

import { formatCurrency } from "./utils/formatCurrency";

function App() {
  const price = 1234.56;
  const formattedPrice = formatCurrency(price, "USD", "en-US");

  return (
    <div>
      <p>Original: {price}</p>
      <p>Formatted: {formattedPrice}</p>
    </div>
  );
}

API

Parameters

ParameterTypeDefaultDescription
amountnumber-The number to format as currency
currencystring"USD"The currency code
localestring"en-US"The locale string

Returns

TypeDescription
stringThe formatted currency string