Open tavvy opened 8 months ago
I have also observed this with useRouter.refresh()
:
useEffect(() => {
new PerformanceObserver((list) => {
if (
(list.getEntries() as PerformanceNavigationTiming[]).find(
({ type }) => type === "reload"
)
) {
console.log("reload"); // only prints on browser refresh, not `useRouter.refresh()`
}
}).observe({ type: "navigation", buffered: true });
}, []);
confirmed still bugged, corewebvitals not returning navigation data, only reload
Link to the code that reproduces this issue
https://github.com/tavvy/nextjs-navigate-event-reproduction
To Reproduce
Current vs. Expected behavior
App router -> App router page navigations should fire PerformanceNavigationTiming "navigate" events so that web vital metrics are collected.
Verify canary release
Provide environment information
Which area(s) are affected? (Select all that apply)
App Router
Additional context
App router -> App router navigations do not fire the "navigate" PerformanceNavigationTiming event.
Pages -> App router and App router -> pages are not impacted.
Please see the reproduction deployment: https://nextjs-navigate-event-reproduction.vercel.app/ Click around and view console logs
I used the vanilla web vitals script https://github.com/GoogleChrome/web-vitals as I want to demonstrate the problem is "outside" of the vercel web vital hook implementations. The same issue is present in the custom vercel / next web vital hook implementations.
I've used
next/link
but the same issue is present withrouter.push()
(my main use case).The main issue is this drastically reduces the number of CWV data points that will be collected for a project. We went from 10,000s per/hour to just 10s! I understand these metrics just wrap browser apis. My concern is this will reflect how the Google CrUX data is collected and site page scores are going to be impacted as the sample size is so small and thus variance in the data is far greater .