Skip to content

Link component is buggy when used in app router #75318

@mehulmpt

Description

@mehulmpt

Link to the code that reproduces this issue

https://github.com/mehulmpt/nextjs-app-router-link-bug

To Reproduce

  1. Clone the GitHub repository
  2. Run npm run bugcheck command in your terminal
  3. Visit http://localhost:3000

Current vs. Expected behavior

Current behavior:

The links rightly point to /link?productid=1 / /link?productid=2 ... and so on. However, when you click on it, they redirect you to the wrong page!

Expected behavior:

Redirect works properly

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.1.0: Thu Oct 10 21:03:15 PDT 2024; root:xnu-11215.41.3~2/RELEASE_ARM64_T6000
  Available memory (MB): 16384
  Available CPU cores: 8
Binaries:
  Node: 18.20.4
  npm: 8.19.2
  Yarn: 1.22.19
  pnpm: 8.7.6
Relevant Packages:
  next: 15.1.3 // There is a newer version (15.1.6) available, upgrade recommended! 
  eslint-config-next: N/A
  react: 19.0.0
  react-dom: 19.0.0
  typescript: 5.7.3
Next.js Config:
  output: export

Which area(s) are affected? (Select all that apply)

Navigation

Which stage(s) are affected? (Select all that apply)

Other (Deployed), Vercel (Deployed), next start (local)

Additional context

I spent 20 minutes debugging this for one of our clients today and finally figured out this is a bug with Next.js itself. The reproduction code above is extremely minimal and does not include anything else other than the required code.

The behavior is very weird, the link shown is correct in the browser preview on the bottom left but the moment it is clicked, it takes you to the wrong page. I am also attaching the video that showcases it:

  • In the first half of the video I show you wrong behavior
  • In the second half of the video I disable javascript and show you how it should actually work
screenshot-000899.mp4

Metadata

Metadata

Assignees

No one assigned

    Labels

    Linking and NavigatingRelated to Next.js linking (e.g., <Link>) and navigation.linear: nextConfirmed issue that is tracked by the Next.js team.locked

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions