@typetrack/nuxt
v0.1.0
Published
Nuxt 4 module (SSR-safe provide/inject registration, automatic route-change pageview tracking) for typetrack.
Maintainers
Readme
@typetrack/nuxt
Nuxt 4 module (SSR-safe provide/inject registration, automatic route-change pageview tracking) for typetrack.
Install
bun add typetrack @typetrack/nuxtRequires Nuxt 4+.
Usage
// app/analytics.ts
import { createAnalytics } from "typetrack";
export default createAnalytics();// nuxt.config.ts
export default defineNuxtConfig({
modules: ["@typetrack/nuxt"],
typetrack: {
analyticsModule: "~/app/analytics",
},
});<!-- any component -->
<script setup lang="ts">
const analytics = useAnalytics(); // auto-imported
</script>
<template>
<button @click="analytics.track('Signup Completed', { plan: 'pro' })">Sign up</button>
</template>analyticsModule must point at an app-authored file that default-exports
a createAnalytics(...)-constructed instance — Nuxt's module setup()
runs at build/config time in Node and can't hold a live instance across
the client/server runtime boundary directly. Automatic pageview tracking
on route change is on by default (autoPageViews: false to disable).
See docs/README.md for the full documentation index.
