vercel / vercel/next.js

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

Open
#90,131 10 comments 8 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Internationalization (i18n) linear: next Pages Router
Dominant language
JavaScript
Stars
142k
Forks
32.4k
Avg merge
2d 14h
Merged PRs (30d)
351

Description

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)

Image

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:

Image

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked CodeSandbox and its next.config domains array, then reproduce the behavior in the Pages Router with next dev, next build, and next start. Compare CSR navigation and SSR reloads for locales listed and not listed in domains. Done means the default domain preserves its defaultLocale, NextLink does not add an incorrect domain, and hydration errors no longer occur.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nextjs, react
Domain
localization, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.