When navigating in a Next JS 14 app using the router, one may notice that when clicking on a Link
component, the URL does not change immediately. Instead, there is a delay before the new page loads. During this transition period, the content from the loading.tsx
file may not appear right away. Even in regular pages (not ISR pages), the loader may show up but still takes time after clicking the link. While it's possible to use history.pushState
to change the URL instantly, the loading screen may still display with a delay.
I attempted to use the usePathname
hook to detect path changes more quickly, however, there was still a noticeable lag in the update. I also experimented with adding history.pushState
within the onClick event of the Link
component, but unfortunately, the loading process remained sluggish.