Skip to content
Docs menu · Vue / Nuxt

Install — Web

Install AnyReplay in Vue and Nuxt

Record Vue and Nuxt apps with AnyReplay: start the browser SDK in main.ts or a client-only Nuxt plugin, then track events and route changes from components.

Vue apps start the recorder where the app is created. Nuxt renders on the server as well, so the recorder goes into a plugin that only runs in the browser. An overview with masking and routing tips is in session replay for Vue and Nuxt.

Install

npm install @anyreplay/browser

Vue 3

import { createRecorder } from '@anyreplay/browser';

export const recorder = createRecorder({
  projectKey: import.meta.env.VITE_ANYREPLAY_KEY,
});

Vue Router in createWebHistory mode navigates with the History API, so route changes are recorded as page views with no extra code.

Nuxt 3

A file in plugins/ whose name ends in .client.ts runs only in the browser, which is exactly where the recorder belongs. Providing the handle makes it available to every component.

import { createRecorder } from '@anyreplay/browser';

export default defineNuxtPlugin(() => {
  const config = useRuntimeConfig();
  const recorder = createRecorder({
    projectKey: config.public.anyreplayKey as string,
  });
  return { provide: { recorder } };
});

Script tag alternative

If you would rather not add a dependency, add the script tag to index.html in Vue, or to app.head.script in nuxt.config.ts, and call window.anyreplay('track', …) instead of the handle.