> ## Documentation Index
> Fetch the complete documentation index at: https://docs.audyr.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Vue / Nuxt

> Add the Audyr widget to Vue 3 and Nuxt 3 applications.

## Vue 3

The simplest approach is to add the script directly to your `index.html`. It will load on every page of your app.

```html title="index.html" theme={null}
<!DOCTYPE html>
<html lang="en">
  <body>
    <div id="app"></div>
    <script type="module" src="/src/main.ts"></script>

    <script
      src="https://app.audyr.com/widget/widget.min.js"
      data-token="YOUR_TOKEN">
    </script>
  </body>
</html>
```

If you need to load the widget programmatically — for example, based on a condition — you can inject it in `App.vue` using `onMounted`:

```vue title="App.vue" theme={null}
<script setup>
import { onMounted } from 'vue'

onMounted(() => {
  const script = document.createElement('script')
  script.src = 'https://app.audyr.com/widget/widget.min.js'
  script.setAttribute('data-token', 'YOUR_TOKEN')
  document.body.appendChild(script)
})
</script>

<template>
  <RouterView />
</template>
```

## Nuxt 3

Use `useHead` in `app.vue` to inject the script globally across all pages:

```vue title="app.vue" theme={null}
<script setup>
useHead({
  script: [
    {
      src: 'https://app.audyr.com/widget/widget.min.js',
      'data-token': 'YOUR_TOKEN',
      defer: true,
    },
  ],
})
</script>

<template>
  <NuxtPage />
</template>
```

Alternatively, configure it in `nuxt.config.ts` to apply it site-wide without touching `app.vue`:

```ts title="nuxt.config.ts" theme={null}
export default defineNuxtConfig({
  app: {
    head: {
      script: [
        {
          src: 'https://app.audyr.com/widget/widget.min.js',
          'data-token': 'YOUR_TOKEN',
          defer: true,
        },
      ],
    },
  },
})
```
