nextjs - 💡(How to fix) Fix Locale detection isn't working correctly after the update from 15.3 to 15.4/15.5 if a domains array is present in next.config [3 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#90131Fetched 2026-04-08 00:20:43
View on GitHub
Comments
3
Participants
3
Timeline
7
Reactions
8
Author
Timeline (top)
commented ×3labeled ×3issue_type_added ×1

Error Message

and a hydration error comes up in the console:

Root Cause

Also SSR adds the domain to the href of the next/links (and because of this also hydration errors)

Code Example

This happens on every environment - local, docker, codesandbox.

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.3.0: Wed Jan 28 20:48:41 PST 2026; root:xnu-12377.81.4~5/RELEASE_ARM64_T6041
  Available memory (MB): 24576
  Available CPU cores: 14
Binaries:
  Node: 22.22.0
  npm: 10.9.4
  Yarn: 4.12.0
  pnpm: N/A
Relevant Packages:
  next: 15.5.12
  eslint-config-next: N/A
  react: 19.1.0
  react-dom: 19.1.0
  typescript: 5.7.2
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/determined-zhukovsky-vzgqvh?workspaceId=ws_XMt216w8w9LTvcfWfEEkxN

To Reproduce

  1. Open codesandbox url
  2. check that the version of next is 15.5.12
  3. run pnpm install
  4. run pnpm dev
  5. you can also open the dev tools in codesandbox to see more information
  6. click on different links in the demo nextjs app to open different locales
  7. the locales listed in the "domains" array will end up taking the defaultLocale of the "domain" and not the defaultLocale of the main domain. The locales not listed in the "domains" array still work correctly
  8. as you can see, the correct value is still present in the req[Symbol.for("NextInternalRequestMeta")]; but it doesn't affect anything.

Current vs. Expected behavior

v15.5 detects the "defaultLocale" of the "domain" in the "domains" array, although being ran on the defaultDomain.

Also SSR adds the domain to the href of the next/links (and because of this also hydration errors)

<img width="347" height="156" alt="Image" src="https://github.com/user-attachments/assets/704d1296-950e-46b6-b5a4-db7632c2338b" />

in v15.3 no issues were present - both the defaultDomain and the domains from the domains array had always the correct defaultLocale. Also the next/links had the correct links without adding the extra "domain".

For even more information pls see "Additional context"

Provide environment information

This happens on every environment - local, docker, codesandbox.

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.3.0: Wed Jan 28 20:48:41 PST 2026; root:xnu-12377.81.4~5/RELEASE_ARM64_T6041
  Available memory (MB): 24576
  Available CPU cores: 14
Binaries:
  Node: 22.22.0
  npm: 10.9.4
  Yarn: 4.12.0
  pnpm: N/A
Relevant Packages:
  next: 15.5.12
  eslint-config-next: N/A
  react: 19.1.0
  react-dom: 19.1.0
  typescript: 5.7.2
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Pages Router, Internationalization (i18n)

Which stage(s) are affected? (Select all that apply)

next dev (local), next build (local), next start (local)

Additional context

Our "default" domain supports all the listed locales. Our other domains (e.g. "example.fr" has only "fr" and "fr-en", "example.nl" has "nl" and "nl-en"), but the same locales are also supported by the default domain.

in the version 15.3 the locale detection worked perfectly for all these cases. On the "real" domains, listed in the "domains" array it worked and still works correctly, but the problem is with the "default" domain, that also supports the same locales.

v15.5 open the preview page in codesandbox default path "/" detects the correct values

locale from GSSP args: de defaultLocale from GSSP args: de locale from NextInternalRequestMeta: de defaultLocale from NextInternalRequestMeta: de router.locale: de router.defaultLocale: de

If you click on a NextLink (CSR) to "/fr" - that is listed in the "domains" array - the router still has the correct value for "router.defaultLocale: de", but the defaultLocale from the args is now wrong (should be "de")

locale from GSSP args: fr defaultLocale from GSSP args: fr locale from NextInternalRequestMeta: fr defaultLocale from NextInternalRequestMeta: de router.locale: fr router.defaultLocale: de

but if you reload (SSR) the same page "/fr" - router.defaultLocale changes to fr and the defaultLocale from the args is also wrong (both should be "de")

locale from GSSP args: fr defaultLocale from GSSP args: fr locale from NextInternalRequestMeta: fr defaultLocale from NextInternalRequestMeta: de router.locale: fr router.defaultLocale: fr

and a hydration error comes up in the console:

<img width="325" height="163" alt="Image" src="https://github.com/user-attachments/assets/393d4655-8d52-41bb-945d-e27bab913b35" />

so the next/link is adding the domain to the href now.

The locales, that are not listed in the domains, like "/it" - are being detected correctly. Also the "complex" locales for the listed domains - "fr-en" or "nl-en" are working absolute fine.

extent analysis

Problem Summary

The issue is with Next.js version 15.5.12, where the default locale of the main domain is not being detected correctly when navigating to a locale listed in the "domains" array.

Root Cause Analysis

The root cause is likely due to a change in how Next.js handles locale detection in version 15.5.

Fix Plan

To fix this issue, you can try the following steps:

Step 1: Downgrade Next.js to version 15.3

If you're using version 15.5, try downgrading to version 15.3, which is the version where the locale detection worked correctly.

Step 2: Use next.config.js to configure locale detection

You can use the next.config.js file to configure how Next.js detects locales. Try adding the following code to your next.config.js file:

module.exports = {
  // ...
  i18n: {
    locales: ['de', 'fr', 'it', 'nl'],
    defaultLocale: 'de',
  },
};

This will configure Next.js to use the de locale as the default locale.

Step 3: Use getServerSideProps to set locale

You can use the getServerSideProps function to set the locale for each page. Try adding the following code to your page component:

import { GetServerSideProps } from 'next';

const MyPage = () => {
  // ...
};

export const getServerSideProps: GetServerSideProps = async (context) => {
  const locale = context.locale || 'de';
  return {
    props: {
      locale,
    },
  };
};

This will set the locale for each page to the default locale de.

Verification

To verify that the fix worked, try the following steps:

  1. Run pnpm dev to start the development

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING