React / Next.js
Your messages come from one directory — messages, public/locales, locales, src/i18n, src/locales or i18n, first match wins — unless next.config names one, which next-intl and next-translate both do. Both layouts are read: namespaced (messages/en/common.json, locale codes from the subdirectory names) and flat (locales/en.json, codes from the file names). Where both are present, namespaced wins.
The default locale is taken from next-intl's routing.{ts,js}, next-translate's i18n.{js,ts,mjs}, or the Pages Router i18n block in next.config, in that order. The locale list still comes from the directory, so a locale declared in routing but absent from messages/ is not invented.
A layer is a scoped locale directory — a Nuxt layer, a workspace package, a shared UI library, or one app in a monorepo. A React project resolves as a single layer named root.
Overrides
| What you want | How |
|---|---|
| Set the default locale | defaultLocale — wins over every derived source |
| Restrict or reorder locales | locales |
| Force this adapter | framework: 'react' |
| Name the directories yourself, or split them into layers | localeDirs + defaultLocale, which hands the project to the generic adapter |
import { defineI18nKitConfig } from '@the-i18n-kit/cli/config'
export default defineI18nKitConfig({
defaultLocale: 'en',
})
defaultLocale.Limits
- A
next.config.jswrapped inwithNextIntl(...)orwithSentryConfig(...)may fail to execute, since those wrappers need their packages installed and their environment present. The CLI warns naming the file and falls back to the directories above, so check the warning if the wrong directory turns up. - Only one locale directory is used. A project keeping messages in two places needs the generic adapter.
- A routing file declaring neither
localesnordefaultLocaleis skipped in favor of the next source.