@theplaintheory/vue

Vue 3 and Nuxt bindings for Plain Theory consent: plugin, useConsent composable and ConsentGate.
146
Install
npm install @theplaintheory/vue
Latest Version:1.0.0
Vue:3
License:MIT
Last Updated:Oct 20, 2026
Links: GitHub  ·  npm
Maintainer: gagank

@theplaintheory/vue

Vue 3 and Nuxt bindings for Plain Theory consent: a plugin, a useConsent composable and consent-gated components, with types. SSR-safe.

npm install @theplaintheory/vue

Set up

// main.ts
import { createApp } from "vue";
import { createPlainConsent } from "@theplaintheory/vue";
import App from "./App.vue";

createApp(App).use(createPlainConsent({ siteKey: "pk_YOUR_SITE_KEY" })).mount("#app");

Nuxt: add the plugin in plugins/plain-consent.client.ts with nuxtApp.vueApp.use(createPlainConsent({ … })). For trackers written into your HTML, also put the script tag first in <head> (from the dashboard's Install page); the plugin detects it and doesn't add a second copy.

Use it

<script setup lang="ts">
import { ConsentGate, ConsentScript, PrivacyChoicesButton, useConsent } from "@theplaintheory/vue";

const { state, ready, allowed, acceptAll, open, setLanguage } = useConsent();
const analytics = allowed("analytics");
</script>

<template>
  <ConsentScript category="analytics" src="https://www.googletagmanager.com/gtag/js?id=G-XXXX" />

  <ConsentGate category="marketing">
    <iframe src="https://www.youtube.com/embed/…" title="Video" />
    <template #fallback><p>Allow marketing cookies to watch this video.</p></template>
  </ConsentGate>

  <p v-if="ready">Analytics {{ analytics ? "on" : "off" }} · {{ state?.language }}</p>
  <PrivacyChoicesButton class="link">Privacy choices</PrivacyChoicesButton>
</template>

useConsent() returns { state, ready, allowed(category), acceptAll, rejectAll, set, open, revoke, setLanguage } and unsubscribes when the component's scope is disposed. State is null on the server and until the script is ready. Everything from @theplaintheory/consent is re-exported.

MIT · Docs

Related Packages

@polyus-studio/vera-cmp

Centralized cookie consent management (CMP) for 30+ sites — a typed wrapper arou...

802 0
@zeste/vue

Vue 3 bindings for zeste: reactive consent state, headless components, SSR-ready...

318 2
@websideproject/nuxt-cookie-consent

GDPR cookie and cookieless-tracking consent for Nuxt 4: banner, floating button,...

451 1
@netipar/consent-vue3

Unstyled Vue 3 composables and components for Laravel Consent

320 0
@lg2/nuxtmodule-consent-gtm

consent gtm nuxt module

5,195 0

Version History

Version Released Vue License
1.0.0 >=3.3 MIT
Pre-releases (1)
Version Released License
0.0.0-stage