# How to install the cookie banner on the Next.js 12 and 11 versions?

> For the complete site index, see [llms.txt](/llms.txt). Every page is also available as Markdown: replace the trailing slash with `.md` (`/pricing/` becomes `/pricing.md`), or send `Accept: text/markdown` to the page URL itself.

Learn how to install the CookieYes cookie banner on your Next.js 12 and below website with this step-by-step guide.

---

**Last updated:** June 2, 2025
**URL:** https://www.cookieyes.com/documentation/install-cookie-banner-on-next-js-12-and-below-versions/

---

To install the cookie banner, navigate to the **pages>_document.js **and add the following steps:
**Step 1: Import the next/script component.**
To load CookieYes in your Next.js application, add the following import statement:




```js
import Script from 'next/script';
```

**Step 2: Add CookieYes Installation code.**
To enable CookieYes on your website, add the CookieYes Installation code:

```js
<script src={'https://cdn-cookieyes.com/client_data/XXXXXXXX/script.js'}>
</script>
```

> **Note: **

> You need to replace ‘XXXXXXXX’ with your CookieYes website key.
>

You can copy your installation code from **Site Settings** from the top navigation panel of your CookieYes dashboard.



![Copy Code](https://assets.cookieyes.com/Copy_Code_42db741cc9.png)

**Step 3: Add the strategy property beforeInteractive.**
To ensure the script loads and executes without delaying the rendering of the page, add the following strategy below the CookieYes script code.

```js
strategy="beforeInteractive"
```

After completing the above steps, the ‘_document.js’ should be like this:

![code](https://assets.cookieyes.com/code_e004014e4a.png)

> **Note**

> CookieYes does not support the crossorigin attribute, as it may cause caching issues when used with the CookieYes script. If your website automatically adds this attribute when using the `Next.js `script component, we recommend using the standard `<script> `tag provided by CookieYes (installation script) instead to ensure that updates are applied immediately.
>
>
>


---

## Structured Data

```json
{
  "@context": "https://schema.org",
  "@graph": [
    {
      "@type": "Article",
      "headline": "How to install the cookie banner on the Next.js 12 and 11 versions?",
      "mainEntityOfPage": {
        "@type": "WebPage",
        "@id": "https://www.cookieyes.com/documentation/install-cookie-banner-on-next-js-12-and-below-versions/"
      },
      "url": "https://www.cookieyes.com/documentation/install-cookie-banner-on-next-js-12-and-below-versions/",
      "publisher": {
        "@type": "Organization",
        "name": "CookieYes",
        "url": "https://www.cookieyes.com",
        "logo": {
          "@type": "ImageObject",
          "url": "https://www.cookieyes.com/cookieyes-logo.png",
          "width": 2048,
          "height": 2048
        }
      },
      "description": "Learn how to install the CookieYes cookie banner on your Next.js 12 and below website with this step-by-step guide.",
      "datePublished": "2023-03-16T09:36:35+00:00",
      "dateModified": "2025-06-02T06:20:40+00:00",
      "author": {
        "@type": "Person",
        "name": "CookieYes Doc Team"
      },
      "image": [
        "https://assets.cookieyes.com/cookieyes.png"
      ]
    },
    {
      "@type": "BreadcrumbList",
      "@id": "https://www.cookieyes.com/documentation/install-cookie-banner-on-next-js-12-and-below-versions/#breadcrumb",
      "itemListElement": [
        {
          "@type": "ListItem",
          "position": 1,
          "name": "Home",
          "item": "https://www.cookieyes.com/"
        },
        {
          "@type": "ListItem",
          "position": 2,
          "name": "Documentation",
          "item": "https://www.cookieyes.com/documentation/"
        },
        {
          "@type": "ListItem",
          "position": 3,
          "name": "How to install the cookie banner on the Next.js 12 and 11 versions?",
          "item": "https://www.cookieyes.com/documentation/install-cookie-banner-on-next-js-12-and-below-versions/"
        }
      ]
    },
    {
      "@type": "WebSite",
      "@id": "https://www.cookieyes.com/#website",
      "url": "https://www.cookieyes.com/",
      "name": "CookieYes",
      "description": "CookieYes is a Google-certified consent management platform that helps businesses comply with GDPR, CCPA, and other global privacy laws.",
      "inLanguage": "en-US",
      "publisher": {
        "@id": "https://www.cookieyes.com/#organization"
      },
      "potentialAction": {
        "@type": "SearchAction",
        "target": {
          "@type": "EntryPoint",
          "urlTemplate": "https://www.cookieyes.com/?s={search_term_string}"
        },
        "query-input": {
          "@type": "PropertyValueSpecification",
          "valueRequired": true,
          "valueName": "search_term_string"
        }
      }
    },
    {
      "@type": "Organization",
      "@id": "https://www.cookieyes.com/#organization",
      "name": "CookieYes",
      "url": "https://www.cookieyes.com/",
      "logo": {
        "@type": "ImageObject",
        "@id": "https://www.cookieyes.com/#/schema/logo/image/",
        "inLanguage": "en-US",
        "url": "https://www.cookieyes.com/cookieyes-logo.png",
        "contentUrl": "https://www.cookieyes.com/cookieyes-logo.png",
        "width": 2048,
        "height": 2048,
        "caption": "CookieYes"
      },
      "image": {
        "@id": "https://www.cookieyes.com/#/schema/logo/image/"
      }
    }
  ]
}
```
