{"record":{"id":"ba5b053663b9d3a6","repo":"vercel/next.js","slug":"specified-i18n-defaultlocale-should-be-a-string-s","errorCode":null,"errorMessage":"Specified i18n.defaultLocale should be a string.\nSee more info here: https://nextjs.org/docs/messages/invalid-i18n-config","messagePattern":"Specified i18n\\.defaultLocale should be a string\\.\nSee more info here: https://nextjs\\.org/docs/messages/invalid-i18n-config","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/next/src/server/config.ts","lineNumber":1222,"sourceCode":"      )\n    }\n\n    if (!Array.isArray(i18n.locales)) {\n      throw new Error(\n        `Specified i18n.locales should be an Array received ${typeof i18n.locales}.\\nSee more info here: https://nextjs.org/docs/messages/invalid-i18n-config`\n      )\n    }\n\n    if (i18n.locales.length > 100 && !silent) {\n      Log.warn(\n        `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`\n      )\n    }\n\n    const defaultLocaleType = typeof i18n.defaultLocale\n\n    if (!i18n.defaultLocale || defaultLocaleType !== 'string') {\n      throw new Error(\n        `Specified i18n.defaultLocale should be a string.\\nSee more info here: https://nextjs.org/docs/messages/invalid-i18n-config`\n      )\n    }\n\n    if (typeof i18n.domains !== 'undefined' && !Array.isArray(i18n.domains)) {\n      throw new Error(\n        `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`\n      )\n    }\n\n    if (i18n.domains) {\n      const invalidDomainItems = i18n.domains.filter((item) => {\n        if (!item || typeof item !== 'object') return true\n        if (!item.defaultLocale) return true\n        if (!item.domain || typeof item.domain !== 'string') return true\n\n        if (item.domain.includes(':')) {\n          console.warn(","sourceCodeStart":1204,"sourceCodeEnd":1240,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/packages/next/src/server/config.ts#L1204-L1240","documentation":"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.","triggerScenarios":"Providing `i18n: { locales: ['en-US'] }` without a `defaultLocale`; setting `defaultLocale: ''`; setting `defaultLocale: null`; setting `defaultLocale: 0`.","commonSituations":"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.","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."],"exampleFix":"// before\nmodule.exports = { i18n: { locales: ['en-US', 'fr'] } }\n// after\nmodule.exports = { i18n: { locales: ['en-US', 'fr'], defaultLocale: 'en-US' } }","handlingStrategy":"type-guard","validationCode":"if (typeof i18n.defaultLocale !== 'string' || i18n.defaultLocale.length === 0) {\n  throw new Error('defaultLocale must be a non-empty string');\n}","typeGuard":"function hasDefaultLocale(i18n: any): i18n is { defaultLocale: string } {\n  return typeof i18n?.defaultLocale === 'string' && i18n.defaultLocale.length > 0;\n}","tryCatchPattern":null,"preventionTips":["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."],"tags":["config","i18n","type-error"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}