Skip to content
npm package

Install COKIQ in Next.js

Use the @cokiq/next helper or next/script in app/layout.tsx (App Router) or pages/_app.tsx (Pages Router).

Install in 3 steps

  1. Install @cokiq/next or import Script from next/script.
  2. Add the COKIQ loader once in the root layout with your production site key.
  3. Build, deploy and check the live domain.

Package install

npm i @cokiq/next

Universal script

Works on any site that allows custom code in the head. Replace YOUR_SITE_KEY with the key from your COKIQ dashboard. Use one install path per site.

<script src="https://cokiq.com/api/s/YOUR_SITE_KEY" data-key="YOUR_SITE_KEY" async></script>

Check that it works

  • The production HTML includes the COKIQ loader.
  • The banner loads once across route changes.
  • Consent evidence appears in the COKIQ dashboard.

Questions

Where should the script go in Next.js?

Once in the root layout (App Router) or _app (Pages Router), so it runs on every route.