vercel/next.js · error
Specified i18n.localeDetection should be undefined or a bool
Error message
Specified i18n.localeDetection should be undefined or a boolean received ${localeDetectionType}.
See more info here: https://nextjs.org/docs/messages/invalid-i18n-config What it means
Thrown at config.ts:1351 when `i18n.localeDetection` is defined but is neither a boolean nor undefined. `localeDetection` controls automatic Accept-Header-based locale redirection; only `true`/`false`/omitted are valid.
Source
Thrown at packages/next/src/server/config.ts:1351
`${[...duplicateLocales].join(', ')}\n` +
`Each locale should be listed only once.\n` +
`See more info here: https://nextjs.org/docs/messages/invalid-i18n-config`
)
}
// make sure default Locale is at the front
i18n.locales = [
i18n.defaultLocale,
...i18n.locales.filter((locale) => locale !== i18n.defaultLocale),
]
const localeDetectionType = typeof i18n.localeDetection
if (
localeDetectionType !== 'boolean' &&
localeDetectionType !== 'undefined'
) {
throw new Error(
`Specified i18n.localeDetection should be undefined or a boolean received ${localeDetectionType}.\nSee more info here: https://nextjs.org/docs/messages/invalid-i18n-config`
)
}
}
if (result.devIndicators !== false && result.devIndicators?.position) {
const { position } = result.devIndicators
const allowedValues = [
'top-left',
'top-right',
'bottom-left',
'bottom-right',
]
if (!allowedValues.includes(position)) {
throw new Error(
`Invalid "devIndicator.position" provided, expected one of ${allowedValues.join(
', 'View on GitHub (pinned to 0ae8c72462)
Solutions
- Use a real boolean: `localeDetection: false`, or omit the key entirely.
- When sourcing from env, coerce explicitly: `localeDetection: process.env.DISABLE !== '1'`.
Example fix
// before
i18n: { locales: ['en-US'], defaultLocale: 'en-US', localeDetection: 'false' }
// after
i18n: { locales: ['en-US'], defaultLocale: 'en-US', localeDetection: false } Defensive patterns
Strategy: type-guard
Validate before calling
if (i18n.localeDetection !== undefined && typeof i18n.localeDetection !== 'boolean') {
throw new Error('localeDetection must be boolean or undefined');
} Type guard
function validLocaleDetection(i18n: any): boolean {
return i18n.localeDetection === undefined || typeof i18n.localeDetection === 'boolean';
} Prevention
- Coerce env-driven values to booleans explicitly.
- Omit the key rather than passing a string if you accept the default.
When it happens
Trigger: `i18n: { localeDetection: 'false' }` (string), `localeDetection: 0`, `localeDetection: null` is allowed (typeof null === 'object', which fails), `localeDetection: 'yes'`.
Common situations: Setting the value from an env var without coercing to a boolean (`process.env.DISABLE_LOCALE_DETECTION` is a string); copy-pasting config examples that quote the boolean.
Related errors
- Specified i18n.locales should be an Array received ${typeof
- Specified i18n.defaultLocale should be a string. See more in
- Specified i18n.domains must be an array of domain objects e.
- Specified i18n.locales must be an array of locale strings e.
- Specified "i18n" cannot be used with "output: export". See m
AI-assisted analysis of vercel/next.js@0ae8c72462 (2026-08-06).
Data as JSON: /api/errors/15b025d90391154d.
Report an issue: GitHub.