You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, yeah, I'll fix this. This happens because the function reference changes.
Hi! I checked your PR — looks good. I had helped clarify the issue earlier, so glad to see it fixed this way. I’ll keep following other issues to keep contributing.
I'm highly motivated to address this issue #79940, "Docs: Documentation for useReportWebVitals in Pages Router causes duplicated CWV reporting," as accurate web performance metrics are crucial for optimization, and misleading documentation directly hinders developers. As an experienced React and TypeScript developer with practical knowledge of Next.js (both Pages and App Routers), I understand the nuances of how hooks behave across different routing paradigms and the importance of precise Web Vitals reporting. My approach would involve thoroughly reproducing the duplicated reporting in a Pages Router environment, deeply debugging the useReportWebVitals hook's lifecycle on soft navigations to pinpoint the exact cause of the re-runs, and then proposing a clear, well-tested fix both in code and documentation to ensure correct CWV reporting for Pages Router users.
Uh oh!
There was an error while loading. Please reload this page.
What is the documentation issue?
Following the official documentation for useReportWebVitals in the Pages Router leads to unexpected duplicate metrics on client-side navigations.
The docs recommend using the hook like this:
But this causes duplicated CWV entries (e.g. LCP, TTFB, etc.) on soft navigations (next/link), likely because the hook re-runs.
Why this matters:
Let me know if you'd like me to submit a PR request to help you with this solution. Thanks!
Is there any context that might help us understand?
#79800
Does the docs page already exist? Please link to it.
https://nextjs.org/docs/pages/api-reference/functions/use-report-web-vitals
The text was updated successfully, but these errors were encountered: