Installation for Nuxt
Install the CookieYes SDK and get a working banner in three steps.
Three steps, about five minutes: install the module, add it to nuxt.config.ts, and render <CookieYesRoot /> once. If you would rather have the files written for you, run npx @cookieyes/cli init. See Quick start.
Prerequisites
| Requirement | Minimum |
|---|---|
| Node.js | 20, or the newer version your Nuxt release requires |
| Nuxt | 4 |
| Vue | 3.5 |
1. Install
npm install @cookieyes/nuxtThis is the only package you install. nuxt and vue are peer dependencies, so the copies your app already has are the ones used. npx nuxi module add @cookieyes/nuxt installs it and adds it to modules in one go.
2. Add the module
export default defineNuxtConfig({
modules: ["@cookieyes/nuxt"],
cookieyes: {
mode: "cookie-only", // the default: no backend needed
regulation: "GDPR", // "GDPR" | "CCPA"
},
});The cookieyes key takes the same configuration as initCookieYes() in the other packages, so a configuration copies across unchanged. Options that hold functions, such as integrations and callbacks, go in app/app.config.ts instead; see Configuration.
There is no stylesheet to import. The module puts the banner's critical CSS in the server HTML and serves the full stylesheet itself.
3. Render it once
<template>
<CookieYesRoot />
<NuxtPage />
</template><CookieYesRoot /> renders the banner, the preferences dialog and the recall button, plus the opt-out dialog when a CCPA regulation can apply. Nuxt imports it for you. Keep it in app.vue, outside <NuxtPage />, so it stays mounted across navigation, and before your page content, so the banner is early in the DOM: screen readers announce it first, and it paints before the rest of the page.
Done. Reload the page and the banner appears. It is already in the server HTML, and a visitor who has chosen before gets no banner at all. If it does not appear, see Common mistakes.
Common mistakes
Failed to resolve component: CookieYesRoot in the console.
@cookieyes/nuxt is missing from modules in nuxt.config.ts. Add it, as in step 2.
Nothing renders: no banner, no error anywhere.
<CookieYesRoot /> is not in app/app.vue. Render it once, as in step 3.
An integration or a callback never runs.
It is in nuxt.config.ts, where options become runtime config, which is JSON and drops functions. Move it under cookieyes in app/app.config.ts. In development the module logs a warning naming the option.
Next steps
- Configuration: every option of the
cookieyeskey, including CCPA and languages - Integrations: load Google Analytics, Meta Pixel and other tags only after consent
- Styling: match the banner to your brand