# useNumberFormat URL: /docs/native/hooks/use-number-format Provider-agnostic number formatting context for Docyrus native components. Mirror of useDateFormat, wired automatically by DocyrusTenantProvider. ## Installation ```bash pnpm dlx @docyrus/cli add @docyrus/rn-hooks-use-number-format ``` The module exports `useNumberFormat()` (hook), `; } ``` ### Custom provider (`Intl`) ```tsx import { NumberFormatProvider } from '@/hooks/docyrus-native/use-number-format'; export function AppProviders({ children }: { children: React.ReactNode }) { return ( ); } ``` ## API Reference ### `useNumberFormat()` Takes no parameters. **Returns:** `NumberFormatContextValue`. | Field | Type | Description | |-------|------|-------------| | `formatNumber` | `(value: unknown, options?: NumberFormatOptions) => string` | Formats a number with the active provider's strategy. | ### `NumberFormatOptions` | Field | Type | Description | |-------|------|-------------| | `variant` | `'number' \| 'currency' \| 'percent'` | Output style. `DocyrusTenantProvider` treats a missing value as `'number'`; for `'percent'` it multiplies by 100 and appends `%`. | | `currency` | `string` | ISO 4217 currency code, used when `variant === 'currency'`. | | `decimalPrecision` | `number` | Override the fraction digits. | | `thousandSeparator` | `string` | Override the thousands separator. | ### `` | Prop | Type | Default | Description | |------|------|---------|-------------| | `formatNumber` | `NumberFormatFn` | — | Required. Backs `useNumberFormat()` inside the tree. | | `children` | `ReactNode` | — | Tree to wrap. | ### `isDefaultNumberFormatContext(ctx)` | Parameter | Type | Description | |-----------|------|-------------| | `ctx` | `NumberFormatContextValue` | A value returned by `useNumberFormat()`. | **Returns:** `boolean`. `true` when `ctx` is the no-provider sentinel rather than a real provider. ## Type Exports | Type | Description | |------|-------------| | `NumberFormatFn` | `(value: unknown, options?: NumberFormatOptions) => string`. | | `NumberFormatOptions` | Options accepted by `formatNumber`. | | `NumberFormatContextValue` | Shape returned by `useNumberFormat()`. |