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

  1. Add `defaultLocale` as a string that matches one of the entries in `locales`.
  2. If using env-driven config, provide a fallback: `defaultLocale: process.env.DEFAULT_LOCALE || 'en-US'`.
  3. 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

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


AI-assisted analysis of vercel/next.js@0ae8c72462 (2026-08-06). Data as JSON: /api/errors/ba5b053663b9d3a6. Report an issue: GitHub.