Open ledbetterljoshua opened 3 days ago
@ledbetterljoshua if you know ahead of time that a URL is in pages router and not app, you can pass prefetch={false}
to the link and it will behave as expected. Tested it here: https://link-bug-reproduction-isskh3bjx-laugharns-projects.vercel.app
@laugharn wow awesome, that works. Interesting to note that if any of the links to the pages router do not have prefetch={false}
then the ones with it set still do not work. But this is super helpful. Thanks!
A maybe unpopular opinion but I often find myself creating a link component with prefetch={false}
by default and opt into prefetching as opposed to vice versa.
Link to the code that reproduces this issue
https://github.com/ledbetterljoshua/link-bug-reproduction
To Reproduce
Live Demo
https://link-bug-reproduction.vercel.app/
Repository
https://github.com/ledbetterljoshua/link-bug-reproduction
Steps to reproduce
link=1
)Current vs. Expected behavior
Current behavior
Each Link component should navigate to the Pages Router page with its specified query parameter intact:
/pages-route?link=1
/pages-route?link=2
/pages-route?link=3
Actual behavior
/pages-route?link=1
)/pages-route?link=1
, ignoring their specified query parametersProvide environment information
Which area(s) are affected? (Select all that apply)
Navigation, Pages Router
Which stage(s) are affected? (Select all that apply)
Vercel (Deployed)
Additional context
Description
When navigating from a page in the App Router to a page in the Pages Router using Next.js Link components, query parameters are not being properly maintained. The first query parameter encountered becomes "sticky" and is used for all subsequent navigations to the Pages Router page, regardless of the actual query parameters specified in the Links and in the DOM.
Additional observations
Environment
Notes
This appears to be a client-side navigation issue, as:
Would appreciate guidance on whether this is a known issue or if there's a recommended workaround while we gradually migrate from Pages Router to App Router.