Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Page reloads when navigating between pages with Link if /pages and /app coexist #53067

Open
1 task done
yjoer opened this issue Jul 23, 2023 · 0 comments
Open
1 task done
Labels
bug Issue was opened via the bug report template. Navigation Related to Next.js linking (e.g., <Link>) and navigation.

Comments

@yjoer
Copy link
Contributor

yjoer commented Jul 23, 2023

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #22 SMP Tue Jan 10 18:39:00 UTC 2023
Binaries:
  Node: 18.16.0
  npm: 9.5.1
  Yarn: 1.22.19
  pnpm: 8.4.0
Relevant Packages:
  next: 13.4.12-canary.0
  eslint-config-next: 13.4.12
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.1.6
Next.js Config:
  output: N/A

Which area(s) of Next.js are affected? (leave empty if unsure)

App Router, Routing (next/router, next/navigation, next/link)

Link to the code that reproduces this issue or a replay of the bug

https://codesandbox.io/p/sandbox/pages-app-coexist-gnyqqc

To Reproduce

The sandbox was started from the Next.js template. I have added the components as shown in the following directory tree:

├─ pages
│   ├─ csb
│   │  └─ [categoryId]
│   │     └─ index.js
│   ├─ explore
│   │  └─ [categoryId]
│   │     └─ index.js
│   └─ explore123
│      └─ [categoryId]
│         └─ index.js
└─ nav.js

All index.js files are identical, displaying the current categoryId. The nav.js renders the links to navigate between pages.

First case:

  1. Go to https://gnyqqc-3002.csb.app/explore123/145959601311842304
  2. Click on "Page 3".
  3. The page reloads.

Second case:

  1. Go to https://gnyqqc-3002.csb.app/csb/145959601370562562
  2. Click on "Page 6".
  3. The page reloads.

Following is the recording for the first case:

1.mp4

Describe the Bug

The page in /pages reloads when navigating between pages with Link from next/link if both /app and /pages coexist. The unwanted behavior does not occur for most variants of preceding URL segments. An example is /explore. I found some positive examples, such as /csb and /explore123, where one out of six of the pages reloads in both cases. Interestingly, changing the preceding segment changes the page that causes the reload.

Expected Behavior

The page must not reload when clicking between links.

The recording below shows the working example when the preceding segment is /explore

2.mp4

Which browser are you using? (if relevant)

Chrome 115.0.5790.99

How are you deploying your application? (if relevant)

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. Navigation Related to Next.js linking (e.g., <Link>) and navigation.
Projects
None yet
Development

No branches or pull requests

1 participant