I am using Next.js 14 in my project and for navigation between pages, I am using the Link
component. The problem is that my scripts do not execute when navigating between pages using Link
, but they do run correctly when the page is refreshed.
When I use an a
tag instead of the Link
component and navigate between pages, everything works fine and the scripts execute. However, I want to use the Link
component from Next.js and have the scripts execute when navigating between pages.
Is there a way to solve this issue? I would appreciate any guidance.
Versions:
- Next.js: 14
- Directory: app
Thank you.
I tried using the Link
component from Next.js for navigation between pages, expecting my scripts to execute as they do when the page is refreshed. However, the scripts did not run when navigating with Link
. To troubleshoot, I replaced the Link
component with an a
tag, and the scripts executed correctly. I expected the Link
component to handle script execution in the same way as the a
tag.