Next.js Discord

Discord Forum

Nextra docs with Web Analytics

Unanswered
Sun bear posted this in #help-forum
Open in Discord
Original message was deleted.

17 Replies

Sun bear
Any guesses?
:cri:
Hello @Sun bear
So, on your layout
You add the following lines:

import { Analytics } from '@vercel/analytics/react';

<Analytics />
If you use /app use
import { Analytics } from '@vercel/analytics/react';
 
export default function RootLayout({ children }) {
  return (
    <html lang="en">
      <head>
        <title>Next.js</title>
      </head>
      <body>
        {children}
        <Analytics />
      </body>
    </html>
  );
}
if you use /pages use
import { Analytics } from '@vercel/analytics/react';
 
function MyApp({ Component, pageProps }) {
  return (
    <>
      <Component {...pageProps} />
      <Analytics />
    </>
  );
}
 
export default MyApp;
@zAguss🦆 So, on your layout
Sun bear
What layout?
Nextra docs does not have it
Or i'm just not finding
I've read the instructions in the docs, but none were for nextra
ok
oooo
mb
npm i @vercel/analytics
import { inject } from '@vercel/analytics';
 
inject();
Sun bear
But in which file it should be?