Optimistic routes wrongly predicts rewritten pages
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 142k
- Forks
- 32.5k
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 351
Description
Link to the code that reproduces this issue
https://github.com/blurrah/repro-optimistic-routes
To Reproduce
- Open vercel deployment
- wait for
/deprefetch to be completed (page will notify) - Click on
Team (no prefetch) - The page will shortly show a marker that it received the wrong locale (
teamas locale)
Current vs. Expected behavior
When using optimisticRoutes with rewritten paths it will wrongly predict the non-rewritten path until the page resolves post-navigation. In this locale based example it means that /team will get team as a locale rather than en. This can lead to all sorts of weird bugs like flashing 404's or wrongly fetched data.
Disabling optimisticRoutes fixes the behavior.
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 24.6.0: Tue Apr 21 20:19:12 PDT 2026; root:xnu-11417.140.69.710.16~1/RELEASE_ARM64_T6041
Available memory (MB): 49152
Available CPU cores: 12
Binaries:
Node: 24.12.0
npm: 11.6.2
Yarn: N/A
pnpm: 10.33.4
Relevant Packages:
next: 16.3.1-canary.7
eslint-config-next: N/A
react: 19.2.8
react-dom: 19.2.8
typescript: 5.9.3
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Linking and Navigating
Which stage(s) are affected? (Select all that apply)
Vercel (Deployed)
Additional context
Tested against latest and canary, happens locally and on Vercel.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked reproduction and verify the failure with optimisticRoutes and rewritten paths, focusing on the linking and navigating area. The payload names no repository files or tests; done means the optimistic prediction preserves the rewritten locale for the reported /de and /team flow.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- next.js
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100