vTilt
Why vTiltHow It WorksFeaturesFAQDocs
Docs / Vue.js
Quick startEvent forwarding
MCP server
Guides
OverviewAuthenticationOAuthAgent skills (prompts)AI intelligenceGoogle Ads
Client setup
CursorClaude DesktopVS CodeCodex
Realtime
Debug ViewRealtime Dashboard
Integration guides
Frontend frameworks
Next.jsNuxt.jsVue.jsReactReact RouterRemixGatsbySvelte / SvelteKitAstroAngularTanStack StartDocusaurus
Backend frameworks
NestJSHonoCloudflare WorkersDjangoFlaskLaravelPhoenixRuby on Rails
Backend languages
PythonPHPRubyElixirGoJava.NET / C#Rust
Stack guides
Vue + PHP
SDK
Browser SDK
InstallScript bundlesEvent trackingAutocaptureIdentify & aliasWeb VitalsSession recordingChat widgetFeature readinessRemote configurationReverse proxyDebug logging
Node SDK
Install & setupCapture, identify & aliasContext & shutdown

Documentation

vTilt
Quick startEvent forwarding

MCP server

Realtime

Debug ViewRealtime Dashboard

Integration guides

Next.jsNuxt.jsVue.jsReactReact RouterRemixGatsbySvelte / SvelteKitAstroAngularTanStack StartDocusaurus

SDK

DocsIntegration guidesVue.js

Vue.js

Integrate vTilt with a standalone Vue 3 app — npm package or inline script, Vue Router pageviews, identify on page load.

vTilt drops into a standalone Vue 3 app (Vite, vue-cli, Vue + Vite SPA). If you have a server-rendered shell, see the Vue + PHP guide for the SSR identify pattern.

#1. Add your environment variables

# .env
VITE_VTILT_TOKEN=YOUR_PROJECT_TOKEN
VITE_VTILT_HOST=https://www.vtilt.com
text

#2. Install & initialise

Choose how you load the Browser SDK. npm initialises the SDK in main.ts; the inline script drops a stub in index.html with no package to install. Both expose the same window.vt global — the rest of this guide is identical either way.

Install the package:

npm install @v-tilt/browser
bash

Boot the SDK before mounting the app so the first paint is captured:

// src/main.ts
import { createApp } from 'vue'
import { vt } from '@v-tilt/browser'
import App from './App.vue'
import { router } from './router'

vt.init(import.meta.env.VITE_VTILT_TOKEN, {
  api_host: import.meta.env.VITE_VTILT_HOST,
  autocapture: true,
  capture_pageview: true,
  capture_pageleave: true,
})

const app = createApp(App)
app.config.globalProperties.$vt = vt
app.provide('vt', vt)
app.use(router)
app.mount('#app')
typescript

Tip

Tip: Need chat on first paint? Swap array.js for array.chat.js and add chat: { enabled: true }. See Script bundles.

#3. Vue Router pageviews

With the standard History API, the SDK patches pushState / replaceState so SPA navigation works automatically. The manual afterEach below is only needed when you bypass it (custom routers, hash-mode). Disable capture_pageview first to avoid double-counting.

// src/router.ts
import { createRouter, createWebHistory } from 'vue-router'
import { vt } from '@v-tilt/browser'

export const router = createRouter({
  history: createWebHistory(),
  routes: [
    /* ... */
  ],
})

router.afterEach((to, from, failure) => {
  if (failure) return
  vt.capture('$pageview', {
    $current_url: window.location.href,
    $pathname: to.fullPath,
    $referrer: from.fullPath,
  })
})
typescript

#4. Use vt from any component

<script setup lang="ts">
import { inject } from 'vue'
import type { vt as VtType } from '@v-tilt/browser'

const vt = inject<typeof VtType>('vt')!

function trackCta() {
  vt.capture('cta_clicked', { location: 'hero' })
}
</script>

<template>
  <button @click="trackCta">Get started</button>
</template>
vue

#5. Identify users

Important

Important: Don't only identify inside your login handler. Visitors arriving with an existing session cookie stay anonymous unless you also identify on every authenticated page load.

// src/auth.ts
import { vt } from '@v-tilt/browser'
import { watchEffect } from 'vue'
import { useUserStore } from './stores/user'

export function setupVtiltIdentity() {
  const store = useUserStore()
  watchEffect(() => {
    if (store.user) {
      vt.identify(store.user.id, {
        email: store.user.email,
        name: store.user.name,
        plan: store.user.plan,
      })
    }
  })
}
typescript

Call setupVtiltIdentity() from a top-level component (App.vue setup()). See Identify & alias for the full model.

#6. Logout

import { vt } from '@v-tilt/browser'

async function logout() {
  vt.capture('user_logged_out')
  vt.resetUser()
  await fetch('/api/auth/logout', { method: 'POST' })
  window.location.href = '/'
}
typescript

#Next steps

  • Vue + PHP integration guide — full server-rendered identify pattern.
  • Nuxt.js integration guide — same SDK with Nuxt's runtime config + plugins.
  • Identify & alias — anonymous → known user merge.
  • Autocapture — what's captured automatically.
PreviousNuxt.jsIntegration guidesNextReactIntegration guides

On this page

  • 1. Add your environment variables
  • 2. Install & initialise
  • 3. Vue Router pageviews
  • 4. Use vt from any component
  • 5. Identify users
  • 6. Logout
  • Next steps