vTilt
Why vTiltHow It WorksFeaturesFAQDocs
Docs / Docusaurus
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 guidesDocusaurus

Docusaurus

Integrate vTilt with Docusaurus — npm client module or inline script, automatic SPA navigation pageviews, optional identify.

Docusaurus is a static documentation site generator. vTilt drops in via a client module (npm) or an injected script tag (inline).

#1. Add your environment variables

# .env
VTILT_TOKEN=YOUR_PROJECT_TOKEN
VTILT_HOST=https://www.vtilt.com
text

#2. Install & initialise

Choose how you load the Browser SDK. npm boots the SDK from a client module; the inline script injects a stub via injectHtmlTags 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

Expose the config and register a client module:

// docusaurus.config.js
module.exports = {
  customFields: {
    vtiltToken: process.env.VTILT_TOKEN,
    vtiltHost: process.env.VTILT_HOST,
  },
  clientModules: [require.resolve('./src/vtilt.ts')],
}
javascript
// src/vtilt.ts
import { vt } from '@v-tilt/browser'
import siteConfig from '@generated/docusaurus.config'

if (typeof window !== 'undefined') {
  const { vtiltToken, vtiltHost } = siteConfig.customFields as Record<
    string,
    string
  >

  vt.init(vtiltToken, {
    api_host: vtiltHost,
    autocapture: true,
    capture_pageview: true,
    capture_pageleave: true,
  })
}
typescript

Note

Note: Docusaurus uses the History API for client-side navigation between docs pages. The SDK auto-patches pushState / replaceState, so SPA pageviews fire automatically when capture_pageview: true.

Tip

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

#3. Identify visitors (optional)

Most docs sites stay anonymous, but if your site has authentication (e.g. customer-only docs gated through a login proxy), identify users on every page load by reading whatever cookie or local-storage value your auth integration sets.

// src/vtilt.ts (continued)
import { vt } from '@v-tilt/browser'

function readUser() {
  try {
    return JSON.parse(localStorage.getItem('docs_user') || 'null')
  } catch {
    return null
  }
}

export function onRouteDidUpdate() {
  const user = readUser()
  if (user) vt.identify(user.id, { email: user.email })
}
typescript

onRouteDidUpdate is the Docusaurus client lifecycle hook that runs after every route change. Using the inline script? Replace vt with window.vt and drop the import.

#4. Capture custom events

// src/components/CtaButton.tsx
import { vt } from '@v-tilt/browser'

export default function CtaButton() {
  return (
    <button
      onClick={() => vt.capture('docs_cta_clicked', { location: 'sidebar' })}
    >
      Try the API
    </button>
  )
}
tsx

#Next steps

  • Autocapture — what's captured automatically.
  • Identify & alias — full identification model.
  • Reverse proxy — block-resistant ingestion.
PreviousTanStack StartIntegration guidesNextNestJSIntegration guides

On this page

  • 1. Add your environment variables
  • 2. Install & initialise
  • 3. Identify visitors (optional)
  • 4. Capture custom events
  • Next steps