diff --git a/docs/advanced-features/i18n-routing.md b/docs/advanced-features/i18n-routing.md index c21b2b9e73d67..5932f80d77461 100644 --- a/docs/advanced-features/i18n-routing.md +++ b/docs/advanced-features/i18n-routing.md @@ -281,3 +281,8 @@ export const getStaticPaths = ({ locales }) => { } } ``` + +## Limits for the i18n config + +- `locales`: 100 total locales +- `domains`: 100 total locale domain items diff --git a/errors/invalid-i18n-config.md b/errors/invalid-i18n-config.md index 1a1be32af8839..b840d14a61f98 100644 --- a/errors/invalid-i18n-config.md +++ b/errors/invalid-i18n-config.md @@ -2,11 +2,11 @@ #### Why This Error -In your `next.config.js` file you provided an invalid config for the `i18n` field. +In your `next.config.js` file you provided an invalid config for the `i18n` field. This could mean the limit for 100 locale items was exceeded. #### Possible Ways to Fix It -Make sure your `i18n` field follows the allowed config shape and values: +Make sure your `i18n` field follows the allowed config shape, limits, and values: ```js module.exports = { diff --git a/packages/next/server/config.ts b/packages/next/server/config.ts index fae751e863a78..9919ca951703e 100644 --- a/packages/next/server/config.ts +++ b/packages/next/server/config.ts @@ -320,6 +320,12 @@ function assignDefaults(userConfig: { [key: string]: any }) { ) } + if (i18n.locales.length > 100) { + throw new Error( + `Received ${i18n.locales.length} i18n.locales items which exceeds the max of 100, please reduce the number of items to continue.\nSee more info here: https://nextjs.org/docs/messages/invalid-i18n-config` + ) + } + const defaultLocaleType = typeof i18n.defaultLocale if (!i18n.defaultLocale || defaultLocaleType !== 'string') {