React Intl is a mature and widely-used library for internationalizing React applications. It provides a comprehensive set of components and an API for formatting dates, numbers, and strings, including complex pluralization and translation handling, leveraging JavaScript's built-in `Intl` API. Currently at version 10.1.2, it is part of the broader FormatJS ecosystem, which also includes tools for message extraction and compilation. The library maintains an active development pace, with regular patch and minor releases, and significant major version updates to keep pace with React and JavaScript ecosystem changes. Its key differentiators include a component-based approach for common UI elements, a hook-based API for imperative formatting, and robust support for ICU MessageFormat syntax, making it a powerful choice for globalized React apps.
npm install react-intlVerified import paths — ran on the pinned version, not inferred.
This quickstart initializes `react-intl` with a French locale and a set of predefined messages. It demonstrates both the declarative `FormattedMessage` component for rendering localized strings with interpolated values and rich text, and the imperative `useIntl` hook for formatting a title. It showcases date, plural, and currency formatting.
Upgrade `react` and `@types/react` to `^19.0.0`. Review the `react-intl` v10 upgrade guide on FormatJS documentation.
Upgrade your Node.js environment to version 16 or newer. For older environments, polyfills for `Intl` APIs might be required.
Update to `react-intl@8.0.0` or newer. This issue was fixed by replacing `cloneElement` with `React.Fragment` internally.
Dynamically import locale data for each language your application supports using a pattern like `import '@formatjs/intl-pluralrules/locale-data/fr';` and ensure polyfills for `Intl` APIs are included for older browser support.
Wrap your root React component (or the relevant sub-tree) with `IntlProvider`, ensuring it receives `locale` and `messages` props.
Flatten your message keys into dot-separated strings or another convention that results in plain string IDs. Ensure consistency for maintainability and tool compatibility.
Ensure that your entire application or the relevant component tree is wrapped within an `IntlProvider` component, providing the `locale` and `messages` props.
Verify that your `react` dependency is at least `16.8.0`. Check your module bundler configuration to ensure `react-intl` is correctly resolved and that you're using a compatible version. Update `react-intl` to a version that supports hooks.
Ensure the `locale` prop passed to `IntlProvider` is always a valid BCP 47 language tag string, such as 'en-US' or 'fr-FR'. Consider a fallback mechanism for determining the user's locale.
Include polyfills for the `Intl` object and specific `Intl` APIs (`Intl.PluralRules`, `Intl.RelativeTimeFormat`, etc.) as needed for your target environments. For Node.js, ensure version 16+ is used.
Ensure you are explicitly importing locale data for all supported languages using `@formatjs/intl-*` packages (e.g., `import '@formatjs/intl-pluralrules/locale-data/fr';`) and that your `IntlProvider` correctly receives the `locale` prop.