Include the Analytics Script with PlausibleProvider
masterTo enable Plausible analytics, wrap your application (or specific pages) with the <PlausibleProvider /> component. You must provide the src prop with your site-specific script URL from the Plausible dashboard (e.g., https://plausible.io/js/pa-XXXXX.js).
Usage in Pages Router (_app.js):
Wrap the top-level component to enable analytics globally.
Usage in App Router (layout.js):
Wrap the children inside the root layout.
Single Page Usage: Wrap only the specific page component where analytics are desired.
// pages/_app.js
import PlausibleProvider from 'next-plausible'
export default function MyApp({ Component, pageProps }) {
return (
<PlausibleProvider src="https://plausible.io/js/pa-XXXXX.js">
<Component {...pageProps} />
</PlausibleProvider>
)
}