Consent that isn’t a mess

Managing cookie consent is a tangle of banners, laws, and provider APIs. Every analytics vendor wants a different knob, and one wrong default can tank your data or your compliance. That’s why we built a small, clear system that separates the UI, storage, and provider syncing. Easy to read, easy to test, easy to swap.

Full flexibility in 3 parts

  • Customize look! - Agnostic banner: the visible modal with Accept, Reject, Customize. It just collects choices and exposes toggleConsentManagement().
  • Customize storage! - Agnostic composable:useConsent() stores decisions in cookies for one year.
  • Customize provider! - Plugin (optional): maps your consent to a specific tool. Example: Google Analytics

How to use it

3.1 Put the composable in place

  1. Save useConsent in composables/useConsent.ts (your project’s version).
  2. Customize cookie settings directly in the composable - only if you need.
  3. Set a cookie prefix in runtime config so environments don’t collide:
    // nuxt.config.ts
    export default defineNuxtConfig({
      runtimeConfig: { public: { consentPrefix: 'myapp' } }
    })

3.2 Embed the banner and add a toggle button

  1. Embed the banner in app.vue or a layout so it can appear on first visit.
  2. Add a button to allow user to reopen the banner after they made a choice. You are free to put it anywhere. You can find example in implementation file.

3.3 Connect a provider or write your own

Example bellow shows how to connect Google Analytics, which is currently the only implemented one. But you can write your own provider plugin to connect any other service. (See the section bellow)

  1. Enable nuxtScripts and add your GA ID:
    // nuxt.config.ts
    scripts: {
        registry: {
          googleAnalytics: {
            id: "G-XXXXXXXXXX",
          },
        },
    },
    
  2. Put provided ga.client plugin in plugins/ga.client.ts

3.4 Creating your own provider

If you need to connect a service that is not supported out of the box, you can create your own provider plugin. Here’s how:

  1. Create a new plugin file in the plugins directory, e.g. plugins/myProvider.ts.
  2. In your plugin, define a new provider using the defineNuxtPlugin function:
    // plugins/myProvider.ts
    export default defineNuxtPlugin(() => {
        // your provider implementation
    })
  3. Provider implementation should
    A) Watch changes in consent state
    B) Translate agnostic consent into provider specific data.
    C) Call the provider API to apply the consent.