vercel/next.js · error
Specified i18n.defaultLocale should be a string. See more in
Error message
Specified i18n.defaultLocale should be a string. See more info here: https://nextjs.org/docs/messages/invalid-i18n-config
What it means
Thrown when `i18n.defaultLocale` is falsy or not a string. The guard `!i18n.defaultLocale || defaultLocaleType !== 'string'` at config.ts:1221 requires a non-empty string, so empty-string, undefined, null, number, or object all fail. `defaultLocale` is the locale Next falls back to when it cannot detect the user's preferred locale.
Source
Thrown at packages/next/src/server/config.ts:1222
)
}
if (!Array.isArray(i18n.locales)) {
throw new Error(
`Specified i18n.locales should be an Array received ${typeof i18n.locales}.\nSee more info here: https://nextjs.org/docs/messages/invalid-i18n-config`
)
}
if (i18n.locales.length > 100 && !silent) {
Log.warn(
`Received ${i18n.locales.length} i18n.locales items which exceeds the recommended max of 100.\nSee more info here: https://nextjs.org/docs/advanced-features/i18n-routing#how-does-this-work-with-static-generation`
)
}
const defaultLocaleType = typeof i18n.defaultLocale
if (!i18n.defaultLocale || defaultLocaleType !== 'string') {
throw new Error(
`Specified i18n.defaultLocale should be a string.\nSee more info here: https://nextjs.org/docs/messages/invalid-i18n-config`
)
}
if (typeof i18n.domains !== 'undefined' && !Array.isArray(i18n.domains)) {
throw new Error(
`Specified i18n.domains must be an array of domain objects e.g. [ { domain: 'example.fr', defaultLocale: 'fr', locales: ['fr'] } ] received ${typeof i18n.domains}.\nSee more info here: https://nextjs.org/docs/messages/invalid-i18n-config`
)
}
if (i18n.domains) {
const invalidDomainItems = i18n.domains.filter((item) => {
if (!item || typeof item !== 'object') return true
if (!item.defaultLocale) return true
if (!item.domain || typeof item.domain !== 'string') return true
if (item.domain.includes(':')) {
console.warn(View on GitHub (pinned to 0ae8c72462)
Solutions
- Add `defaultLocale` as a string that matches one of the entries in `locales`.
- If using env-driven config, provide a fallback: `defaultLocale: process.env.DEFAULT_LOCALE || 'en-US'`.
- Ensure the value is a string literal, not an object or array.
Example fix
// before
module.exports = { i18n: { locales: ['en-US', 'fr'] } }
// after
module.exports = { i18n: { locales: ['en-US', 'fr'], defaultLocale: 'en-US' } } Defensive patterns
Strategy: type-guard
Validate before calling
if (typeof i18n.defaultLocale !== 'string' || i18n.defaultLocale.length === 0) {
throw new Error('defaultLocale must be a non-empty string');
} Type guard
function hasDefaultLocale(i18n: any): i18n is { defaultLocale: string } {
return typeof i18n?.defaultLocale === 'string' && i18n.defaultLocale.length > 0;
} Prevention
- Provide a non-empty string default backed by an env var with a fallback.
- Type the config with NextConfig so missing defaultLocale is a compile error when i18n is present.
When it happens
Trigger: Providing `i18n: { locales: ['en-US'] }` without a `defaultLocale`; setting `defaultLocale: ''`; setting `defaultLocale: null`; setting `defaultLocale: 0`.
Common situations: Forgetting the field after copying a partial config snippet; assuming Next infers a default from `locales[0]`; refactoring that temporarily nulls the value; env-driven config where the env var is unset and falls through to undefined.
Related errors
- Specified i18n.locales should be an Array received ${typeof
- Specified i18n.domains must be an array of domain objects e.
- Specified i18n.locales must be an array of locale strings e.
- Specified i18n.localeDetection should be undefined or a bool
- 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/ba5b053663b9d3a6.
Report an issue: GitHub.