Connect Oraami to Next.js

Install the browser tracker in Next.js, connect your analytics consent choice and verify the first saved visit.

Updated Oraami Inc

Install the web library

Register the website in Oraami and copy its public site key and collector origin from Settings → Installation. Use one installation per document. Allow the collector in your site’s script-src and connect-src policies.

npm install https://app.oraami.com/downloads/oraami-web-1.0.0.tgz

Add the tracker to your application

Render the client component inside the body in app/layout.jsx or from _app in the Pages Router. Initialize your consent banner in the browser.

'use client';
import { useOraami } from '@oraami/web/next';
import { options, consent } from './oraami-config.js';
export default function OraamiTracker() { useOraami(options, consent); return null; }

Check the first visit

  1. Open the registered origin. Decline analytics and check that no event or replay uploads start. The tracker script and site configuration may load.
  2. Grant analytics consent, navigate and open Capture health in Oraami. Check that a new batch was saved for this website.
  3. Withdraw consent, interact again and verify that new uploads stop. Reload to check the remembered choice.

Related guides