"next-axiom" has no exported member named 'reportWebVitals'. Did you mean 'useReportWebVitals'?
maxmandia opened this issue · 5 comments
Can't find the correct exported member - is the documentation outdated?
Agreed! Documentation is here, and it still uses reportWebVitals
:
export { reportWebVitals } from 'next-axiom';
According to Next docs the correct hook is really useReportWebVitals
, as exported from next-axiom
.
@zoul It looks like the useReportWebVitals
function is actually from 'next/web-vitals'
, not next-axiom
. Confusing naming, though, that both Next and Axiom would have functions for similar purposes that are named exactly the same.
I'm working on a project that still uses the Pages router, but this link makes it look like the API is now just a component that you add to your layout.tsx (if you're using the App router).
Unclear if one would add this to their _app or _document file if using the Pages router.
To me it looks as though next-axiom
just re-exports the useReportWebVitals
function from next/web-vitals
, see here. So it’s not two different functions under the same name, but one. Makes sense, maybe they want to customize the code for Axiom later without changing the API.
@zoul you nailed it. The useReportWebVitals
hooks was added to Next.js as a contribution from Axiom. We use it but we provide the current pathname to the values before sending those data to Axiom. We used the same name to be consistent.
@zoul It looks like the
useReportWebVitals
function is actually from'next/web-vitals'
, notnext-axiom
. Confusing naming, though, that both Next and Axiom would have functions for similar purposes that are named exactly the same.I'm working on a project that still uses the Pages router, but this link makes it look like the API is now just a component that you add to your layout.tsx (if you're using the App router).
Unclear if one would add this to their _app or _document file if using the Pages router.
The current version supports the App navigation method, for the legacy navigation you could fallback for v0.18.0 If I recall correctly.