Install on Next.js / Developer Setup
Add Cromojo in a modern JavaScript framework
Written By David
Last updated 24 days ago
For Next.js (and most modern frameworks), the cleanest way to load the Cromojo script is with the framework's script component, placed in your root layout so it runs on every route.
Add the script
In Cromojo, go to Settings β Analytics and copy your site ID (the data-site-id value).
Open your root layout (in the Next.js App Router, that's app/layout.tsx).
Import Next's Script component and add it inside the <body>, as shown below.
Deploy your app.
Verify
Back in Cromojo, open Settings β Analytics and click Verify Installation, or visit your own site and watch for your visit to appear on the dashboard within a minute or two.