vercel / vercel/next.js

Optimistic routes wrongly predicts rewritten pages

Open
#96,893 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Linking and Navigating
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
  1. Open vercel deployment
  2. wait for /de prefetch to be completed (page will notify)
  3. Click on Team (no prefetch)
  4. The page will shortly show a marker that it received the wrong locale (team as 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

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.