[PR #471] [MERGED] feat: Add Pages Router i18n domain routing #598

Closed
opened 2026-05-06 13:08:59 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/471
Author: @NathanDrake2406
Created: 3/11/2026
Status: Merged
Merged: 3/12/2026
Merged by: @james-elicx

Base: mainHead: feat/i18n-domains-pages-router


📝 Commits (10+)

  • 3db1ba5 Add Pages Router domain locale routing
  • b0c16e9 Add coverage for Pages Router domain locale behavior
  • 401d1d3 Format Pages Router i18n domain routing changes
  • f9d9883 Handle basePath in Pages Router i18n domains
  • 0ac02be Refactor Pages Router i18n domain fixtures
  • 7d51853 Update Pages Router entry snapshot after rebase
  • 96bfee9 Align domain locale redirects with Next.js
  • 836745b Clarify Pages Router domain locale helpers
  • 22bf599 Fix case-insensitive locale prefixes
  • 43b679f Simplify same-domain locale URL handling

📊 Changes

23 files changed (+1306 additions, -163 deletions)

View changed files

📝 packages/vinext/src/check.ts (+5 -2)
📝 packages/vinext/src/entries/pages-server-entry.ts (+33 -21)
📝 packages/vinext/src/global.d.ts (+18 -0)
📝 packages/vinext/src/index.ts (+2 -0)
📝 packages/vinext/src/server/dev-server.ts (+45 -90)
packages/vinext/src/server/pages-i18n.ts (+233 -0)
📝 packages/vinext/src/shims/internal/utils.ts (+1 -0)
📝 packages/vinext/src/shims/link.tsx (+27 -11)
📝 packages/vinext/src/shims/router.ts (+35 -8)
packages/vinext/src/utils/domain-locale.ts (+95 -0)
📝 tests/__snapshots__/entry-templates.test.ts.snap (+28 -21)
📝 tests/check.test.ts (+2 -2)
📝 tests/features.test.ts (+227 -6)
tests/fixtures/pages-i18n-domains-basepath/next.config.mjs (+12 -0)
tests/fixtures/pages-i18n-domains-basepath/pages/about.tsx (+17 -0)
tests/fixtures/pages-i18n-domains-basepath/pages/index.tsx (+3 -0)
tests/fixtures/pages-i18n-domains/next.config.mjs (+10 -0)
tests/fixtures/pages-i18n-domains/pages/about.tsx (+17 -0)
tests/fixtures/pages-i18n-domains/pages/index.tsx (+3 -0)
📝 tests/helpers.ts (+77 -2)

...and 3 more files

📄 Description

Summary

Add Pages Router support for i18n.domains, including domain-aware redirects, request context, and client/server locale links.

What Changed

  • add a shared pages-i18n helper to resolve domain locales, root locale-detection redirects, and per-domain default locales
  • wire Pages Router dev and generated server entries through that helper so locale, defaultLocale, and domainLocales stay in sync
  • include domainLocales in __NEXT_DATA__ and teach the router/link shims to build cross-domain locale URLs
  • seed SSR-only domain locale globals so next/link renders the correct domain href before hydration
  • update the config checker to mark i18n.domains as partial support for Pages Router
  • add unit, dev-server, and production coverage for domain routing, SSR link output, and query-string preservation on locale redirects

Why It Matters

Pages Router apps with locale domains can now route / to the preferred locale domain, use the matched domain default locale in data fetching, and render locale switcher links that point at the right domain from the first HTML response.

Risks Or Limits

  • this is still Pages Router-only support; App Router behavior is unchanged
  • the SSR link fix uses the existing Pages Router SSR global boundary, so the behavior is correct but still follows the current global-state design in this area

Verification

  • pnpm test tests/link.test.ts tests/pages-i18n.test.ts
  • pnpm test tests/features.test.ts tests/pages-i18n-prod.test.ts -t "i18n domain routing"

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/cloudflare/vinext/pull/471 **Author:** [@NathanDrake2406](https://github.com/NathanDrake2406) **Created:** 3/11/2026 **Status:** ✅ Merged **Merged:** 3/12/2026 **Merged by:** [@james-elicx](https://github.com/james-elicx) **Base:** `main` ← **Head:** `feat/i18n-domains-pages-router` --- ### 📝 Commits (10+) - [`3db1ba5`](https://github.com/cloudflare/vinext/commit/3db1ba59fa4d7c620f920dd65a5b5d1c5748492b) Add Pages Router domain locale routing - [`b0c16e9`](https://github.com/cloudflare/vinext/commit/b0c16e9f3054de1eba35bef46ee191f9b73a2704) Add coverage for Pages Router domain locale behavior - [`401d1d3`](https://github.com/cloudflare/vinext/commit/401d1d3dfba9bd35a6daeb55f8065f8a7bf4d2f0) Format Pages Router i18n domain routing changes - [`f9d9883`](https://github.com/cloudflare/vinext/commit/f9d9883050c710026476e4d5216613b2b8776def) Handle basePath in Pages Router i18n domains - [`0ac02be`](https://github.com/cloudflare/vinext/commit/0ac02be059c7335ac226159dcd361b4b66eeb4a8) Refactor Pages Router i18n domain fixtures - [`7d51853`](https://github.com/cloudflare/vinext/commit/7d5185331fbafe6126d3448f25569c062004b6e1) Update Pages Router entry snapshot after rebase - [`96bfee9`](https://github.com/cloudflare/vinext/commit/96bfee946e0f8fc1ca3366d1df395d467d0069c5) Align domain locale redirects with Next.js - [`836745b`](https://github.com/cloudflare/vinext/commit/836745ba07f3ce727ebb0952aaea59b30248bffa) Clarify Pages Router domain locale helpers - [`22bf599`](https://github.com/cloudflare/vinext/commit/22bf59988adcd50421ede5b09af2e04136d5a6e1) Fix case-insensitive locale prefixes - [`43b679f`](https://github.com/cloudflare/vinext/commit/43b679f8461191282009c9f4821c20456e63385f) Simplify same-domain locale URL handling ### 📊 Changes **23 files changed** (+1306 additions, -163 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/check.ts` (+5 -2) 📝 `packages/vinext/src/entries/pages-server-entry.ts` (+33 -21) 📝 `packages/vinext/src/global.d.ts` (+18 -0) 📝 `packages/vinext/src/index.ts` (+2 -0) 📝 `packages/vinext/src/server/dev-server.ts` (+45 -90) ➕ `packages/vinext/src/server/pages-i18n.ts` (+233 -0) 📝 `packages/vinext/src/shims/internal/utils.ts` (+1 -0) 📝 `packages/vinext/src/shims/link.tsx` (+27 -11) 📝 `packages/vinext/src/shims/router.ts` (+35 -8) ➕ `packages/vinext/src/utils/domain-locale.ts` (+95 -0) 📝 `tests/__snapshots__/entry-templates.test.ts.snap` (+28 -21) 📝 `tests/check.test.ts` (+2 -2) 📝 `tests/features.test.ts` (+227 -6) ➕ `tests/fixtures/pages-i18n-domains-basepath/next.config.mjs` (+12 -0) ➕ `tests/fixtures/pages-i18n-domains-basepath/pages/about.tsx` (+17 -0) ➕ `tests/fixtures/pages-i18n-domains-basepath/pages/index.tsx` (+3 -0) ➕ `tests/fixtures/pages-i18n-domains/next.config.mjs` (+10 -0) ➕ `tests/fixtures/pages-i18n-domains/pages/about.tsx` (+17 -0) ➕ `tests/fixtures/pages-i18n-domains/pages/index.tsx` (+3 -0) 📝 `tests/helpers.ts` (+77 -2) _...and 3 more files_ </details> ### 📄 Description ## Summary Add Pages Router support for `i18n.domains`, including domain-aware redirects, request context, and client/server locale links. ## What Changed - add a shared `pages-i18n` helper to resolve domain locales, root locale-detection redirects, and per-domain default locales - wire Pages Router dev and generated server entries through that helper so `locale`, `defaultLocale`, and `domainLocales` stay in sync - include `domainLocales` in `__NEXT_DATA__` and teach the router/link shims to build cross-domain locale URLs - seed SSR-only domain locale globals so `next/link` renders the correct domain href before hydration - update the config checker to mark `i18n.domains` as partial support for Pages Router - add unit, dev-server, and production coverage for domain routing, SSR link output, and query-string preservation on locale redirects ## Why It Matters Pages Router apps with locale domains can now route `/` to the preferred locale domain, use the matched domain default locale in data fetching, and render locale switcher links that point at the right domain from the first HTML response. ## Risks Or Limits - this is still Pages Router-only support; App Router behavior is unchanged - the SSR link fix uses the existing Pages Router SSR global boundary, so the behavior is correct but still follows the current global-state design in this area ## Verification - `pnpm test tests/link.test.ts tests/pages-i18n.test.ts` - `pnpm test tests/features.test.ts tests/pages-i18n-prod.test.ts -t "i18n domain routing"` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 13:08:59 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vinext#598
No description provided.