{"record":{"id":"da752c237df90828","repo":"vercel/next.js","slug":"specified-i18n-should-be-an-object-received-i18n","errorCode":null,"errorMessage":"Specified i18n should be an object received ${i18nType}.\nSee more info here: https://nextjs.org/docs/messages/invalid-i18n-config","messagePattern":"Specified i18n should be an object received (.+?)\\.\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":1202,"sourceCode":"    }\n  }\n  if (!rootDir) {\n    throw new Error(\n      'Failed to find the root directory of the project. This is a bug in Next.js.'\n    )\n  }\n  // Ensure both properties are set to the same value\n  result.outputFileTracingRoot = rootDir\n  dset(result, ['turbopack', 'root'], rootDir)\n\n  setHttpClientAndAgentOptions(result || defaultConfig)\n\n  if (result.i18n) {\n    const { i18n } = result\n    const i18nType = typeof i18n\n\n    if (i18nType !== 'object') {\n      throw new Error(\n        `Specified i18n should be an object received ${i18nType}.\\nSee more info here: https://nextjs.org/docs/messages/invalid-i18n-config`\n      )\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","sourceCodeStart":1184,"sourceCodeEnd":1220,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/packages/next/src/server/config.ts#L1184-L1220","documentation":"When `i18n` is provided it must be an object describing locales, defaultLocale, and domains. The guard at config.ts:1197-1205 runs before any sub-property checks; a truthy non-object value (string, number, array, boolean) is rejected immediately. This protects the subsequent `i18n.locales` / `i18n.defaultLocale` accesses from throwing confusing errors.","triggerScenarios":"Setting `i18n: 'en'`, `i18n: ['en', 'fr']`, or `i18n: true`. The guard only fires when i18n is truthy and `typeof i18n !== 'object'` (note: arrays are `typeof 'object'` and pass this check, but fail later on `locales`).","commonSituations":"Confusing i18n with a locales-array shortcut. Misreading docs and supplying just a default locale string. Bad config merge leaving i18n as a primitive.","solutions":["Set i18n to a full object: `i18n: { locales: ['en', 'fr'], defaultLocale: 'en' }`.","If you do not need i18n routing, remove the `i18n` key entirely (i18n routing is also a Pages Router feature and is not used by the App Router).","Type your config as NextConfig to catch the shape at compile time."],"exampleFix":"// before\nmodule.exports = { i18n: 'en' }\n// after\nmodule.exports = { i18n: { locales: ['en', 'fr'], defaultLocale: 'en' } }","handlingStrategy":"type-guard","validationCode":"if (config.i18n != null && (typeof config.i18n !== 'object' || Array.isArray(config.i18n))) {\n  throw new Error('i18n must be a plain object');\n}","typeGuard":"function isI18nConfig(v: unknown): v is { locales: string[]; defaultLocale: string; domains?: unknown[] } {\n  if (typeof v !== 'object' || v === null || Array.isArray(v)) return false;\n  const o = v as any;\n  return Array.isArray(o.locales) && typeof o.defaultLocale === 'string';\n}","tryCatchPattern":null,"preventionTips":["Type next.config as NextConfig so i18n shape errors surface at compile time.","Remember i18n is a Pages Router feature; App Router uses routing conventions instead."],"tags":["config","i18n","routing","next-config","type-validation"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}