storybook-react-i18next is a Storybook addon that provides seamless integration for react-i18next, enabling developers to test and showcase their localized React components directly within Storybook stories. The current stable version is 10.1.2, which supports Storybook v10, i18next v26, and react-i18next v17. The project maintains an active release cadence, frequently updating to support the latest major versions of its core peer dependencies (Storybook, i18next, and react-i18next). Its primary differentiator is simplifying the process of switching locales within the Storybook UI, allowing designers and developers to easily verify internationalization implementations without complex manual setup per story. It requires pre-existing i18next and react-i18next configurations in the consuming project.
npm install storybook-react-i18nextVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to integrate `storybook-react-i18next` into your Storybook project, including configuring your `main.ts` for addon registration, setting up a basic `i18next.ts` instance with sample resources, and configuring `preview.ts` to enable locale switching in the Storybook toolbar.
Consult the `storybook-react-i18next` README or `package.json` peer dependencies to determine the correct addon version for your Storybook installation, and upgrade or downgrade accordingly.
Always check the addon's peer dependency ranges before upgrading i18n-related packages. Use `npm install --legacy-peer-deps` as a temporary measure if conflicts arise, but the recommended fix is to align versions of all related packages.
Ensure you have `i18next`, `react-i18next`, and any necessary plugins (like `i18next-browser-languagedetector` or `i18next-http-backend`) installed and properly configured in your application before attempting to integrate this Storybook addon.
Follow the detailed usage instructions in the addon's README, paying close attention to the `.storybook/i18next.ts` and `.storybook/preview.ts` setup steps, including `initialGlobals` and `parameters.i18n`.
This issue was quickly addressed in subsequent patches. Ensure you are on the latest stable version (currently 10.x) to avoid any legacy peer dependency quirks related to `react`.
Install all necessary peer dependencies using `npm install i18next react-i18next i18next-browser-languagedetector i18next-http-backend` and ensure their versions align with the `storybook-react-i18next` peer dependency ranges.
Verify that your `.storybook/preview.ts` correctly imports your i18n instance and passes it to `parameters.i18n`, and that `initialGlobals.locale` and `initialGlobals.locales` are defined as shown in the quickstart example.
Double-check the `resources` object and `ns` array in your `.storybook/i18next.ts` to ensure that translation files are correctly loaded and accessible, and that `defaultNS` is set appropriately.
Update your Storybook installation to the version required by the addon (e.g., Storybook v10 for `storybook-react-i18next` v10.x). Review all i18n-related package versions (`i18next`, `react-i18next`, etc.) and ensure they fall within the addon's specified peer dependency ranges. You may temporarily use `npm install --legacy-peer-deps` but strive for full compatibility.