---
title: "useScriptTriggerConsent · Nuxt Scripts"
meta:
  description: "Nuxt Scripts lets you load third-party scripts with better performance, privacy, security and DX. It includes many popular third-parties out of the box."
  "og:description": "Nuxt Scripts lets you load third-party scripts with better performance, privacy, security and DX. It includes many popular third-parties out of the box."
  "og:title": "useScriptTriggerConsent · Nuxt Scripts"
---

```

Nuxt Scripts on GitHub

**

**Api**

# **useScriptTriggerConsent**

[Copy for LLMs](https://scripts.nuxt.com/docs/v0/api/use-script-trigger-consent.md)

Load a script once consent has been provided either through a resolvable `consent` or calling the `accept` method.

The trigger by itself does nothing - scripts will only load when consent is granted through either the `accept()` method or by providing a `consent` option that resolves to `true`.

## Signature

```
function useScriptTriggerConsent(options?: ConsentScriptTriggerOptions): UseConsentScriptTriggerApi {}
```## Arguments```
export interface ConsentScriptTriggerOptions {
  /**
   * An optional reactive (or promise) reference to the consent state. You can use this to accept the consent for scripts
   * instead of using the accept() method.
   */
  consent?: Promise<boolean | void> | Ref<boolean> | ComputedRef<boolean> | boolean
  /**
   * Should the script be loaded on the \`requestIdleCallback\` callback. This is useful for non-essential scripts that
   * have already been consented to be loaded.
   */
  postConsentTrigger?: NuxtUseScriptOptions['trigger']
}
```## Returns A extended promise api with an `accept` method to accept the consent and load the script.```
interface UseConsentScriptTriggerApi extends Promise<void> {
  /**
   * A function that can be called to accept the consent and load the script.
   */
  accept: () => void
}
```## Examples ### Basic Usageapp.vue```
<script setup lang="ts">
const trigger = useScriptTriggerConsent()
useScript('https://example.com/script.js', { trigger })
</script>

<template>
  <button @click="trigger.accept">
    Accept Consent
  </button>
</template>
```[~~Edit this page~~](https://github.com/nuxt/scripts/edit/0.x/docs/content/docs/v0/3.api/3.use-script-trigger-consent.md) [~~Markdown For LLMs~~](https://scripts.nuxt.com/docs/v0/api/use-script-trigger-consent.md) [**useScript** API documentation for the useScript function.](https://scripts.nuxt.com/docs/v0/api/use-script) [**useScriptTriggerElement** API documentation for the useScriptTriggerElement function.](https://scripts.nuxt.com/docs/v0/api/use-script-trigger-element)**On this page **- [Signature](#signature) - [Arguments](#arguments) - [Returns](#returns) - [Examples](#examples)