[PR #878] [MERGED] [codex] Fix usePathname hydration snapshot #914

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

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/878
Author: @southpolesteve
Created: 4/24/2026
Status: Merged
Merged: 4/24/2026
Merged by: @james-elicx

Base: mainHead: codex/fix-usepathname-hydration


📝 Commits (1)

  • d96404d fix usePathname hydration snapshot

📊 Changes

2 files changed (+114 additions, -0 deletions)

View changed files

📝 packages/vinext/src/shims/navigation.ts (+30 -0)
📝 tests/shims.test.ts (+84 -0)

📄 Description

Fixes #871.

Summary

  • Share the browser hydration navigation context through a Symbol.for global so split next/navigation module instances read the same initial snapshot.
  • Keep server-side ALS access unchanged while preventing client usePathname(), useSearchParams(), and useParams() from falling back to / during hydration.
  • Add a regression test that loads separate setter/hook module instances and verifies the hydrated pathname, query, and params stay in sync.

Validation

  • pnpm test tests/shims.test.ts -t "shares the hydrated navigation snapshot"
  • pnpm test tests/nextjs-compat/use-client-page-pathname.test.ts tests/nextjs-compat/rsc-context-lazy-stream.test.ts

🔄 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/878 **Author:** [@southpolesteve](https://github.com/southpolesteve) **Created:** 4/24/2026 **Status:** ✅ Merged **Merged:** 4/24/2026 **Merged by:** [@james-elicx](https://github.com/james-elicx) **Base:** `main` ← **Head:** `codex/fix-usepathname-hydration` --- ### 📝 Commits (1) - [`d96404d`](https://github.com/cloudflare/vinext/commit/d96404dd2710aaa06d94b43bdde4d72af36928f4) fix usePathname hydration snapshot ### 📊 Changes **2 files changed** (+114 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/shims/navigation.ts` (+30 -0) 📝 `tests/shims.test.ts` (+84 -0) </details> ### 📄 Description Fixes #871. ## Summary - Share the browser hydration navigation context through a `Symbol.for` global so split `next/navigation` module instances read the same initial snapshot. - Keep server-side ALS access unchanged while preventing client `usePathname()`, `useSearchParams()`, and `useParams()` from falling back to `/` during hydration. - Add a regression test that loads separate setter/hook module instances and verifies the hydrated pathname, query, and params stay in sync. ## Validation - `pnpm test tests/shims.test.ts -t "shares the hydrated navigation snapshot"` - `pnpm test tests/nextjs-compat/use-client-page-pathname.test.ts tests/nextjs-compat/rsc-context-lazy-stream.test.ts` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 13:10:48 +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#914
No description provided.