Skip to content

Vue Plugin API

createConsentPlugin

Creates a Vue plugin for consent management.

typescript
import { createConsentPlugin } from '@structured-world/vue-privacy/vue';

app.use(createConsentPlugin(options));

Options

See ConsentConfig for all options.

useConsent

Composable for accessing consent state and methods.

typescript
import { useConsent } from '@structured-world/vue-privacy/vue';

const {
  consent,
  isEU,
  hasConsent,
  acceptAll,
  rejectAll,
  resetConsent,
  savePreferences,
} = useConsent();

Returns

PropertyTypeDescription
consentRef<StoredConsent | null>Current consent state
isEURef<boolean>Whether user is in EU
hasConsentRef<boolean>Whether user has given consent
acceptAll() => Promise<void>Accept all categories
rejectAll() => Promise<void>Reject non-essential
resetConsent() => voidClear consent and show banner
savePreferences(categories) => Promise<void>Save specific preferences

ConsentBanner

Vue component for the consent banner.

vue
<ConsentBanner
  position="bottom"
  :config="{ title: 'Custom' }"
  @accept="onAccept"
  @reject="onReject"
  @customize="onCustomize"
/>

Props

PropTypeDefaultDescription
position'bottom' | 'top' | 'center''bottom'Banner position
configPartial<BannerConfig>{}Override banner config

Events

EventDescription
acceptEmitted when user accepts all
rejectEmitted when user rejects
customizeEmitted when user clicks customize

Slots

The component uses Teleport to render at body level. No slots available.

VitePress

enhanceWithConsent

Enhance a VitePress theme with consent.

typescript
import { enhanceWithConsent } from '@structured-world/vue-privacy/vitepress';

export default enhanceWithConsent(DefaultTheme, options);

Quasar

consentBoot

Create a Quasar boot function.

typescript
import { consentBoot } from '@structured-world/vue-privacy/quasar';

export default boot(consentBoot(options));

Released under the Apache 2.0 License. Powered by structured.world