# Vue install

> Vue and Nuxt guidance for installing the v1 widget and updating context on route changes.

## Agent-ready snippet

```
import { onMounted, watch } from 'vue';
import { useRoute } from 'vue-router';

export function useAnswerlatticeInstall(widgetKey: string) {
  const route = useRoute();

  const updateContext = () => {
    if (!widgetKey) return;
    window.AnswerlatticeWidget?.page({
      path: route.path,
      title: document.title,
      feature: route.path.split('/').filter(Boolean)[0] || 'app',
      role: 'member',
      locale: navigator.language || 'en',
    });
  };

  onMounted(() => {
    if (!document.querySelector('script[data-answerlattice-widget="v1"]')) {
      const script = document.createElement('script');
      script.src = 'https://answerlattice.com/widget/v1/answerlattice-widget.js';
      script.async = true;
      script.setAttribute('data-answerlattice-widget', 'v1');
      script.setAttribute('data-answerlattice-key', widgetKey);
      document.head.appendChild(script);
    }
    updateContext();
  });

  watch(() => route.path, updateContext);
}
```

## Public API note

The public API may be account-gated. For most clients, install the AnswerLattice widget first.