init() inside useEffect in _app.tsx so it only runs in the browser:
history.pushState — no extra setup needed.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Install Tracelit in a Next.js Pages Router project via _app.tsx. SSR-safe with automatic SPA route tracking.
npm install @tracelit/tracker
init() inside useEffect in _app.tsx so it only runs in the browser:
// pages/_app.tsx
import { useEffect } from 'react'
import { init } from '@tracelit/tracker'
import type { AppProps } from 'next/app'
export default function App({ Component, pageProps }: AppProps) {
useEffect(() => {
init({ token: 'YOUR_TOKEN_HERE', environment: 'production' })
}, [])
return <Component {...pageProps} />
}
environment. Only "production" and "development" are accepted. If omitted, events default to development.history.pushState — no extra setup needed.
// pages/_app.tsx
import { useEffect } from 'react'
import { init, identify, reset } from '@tracelit/tracker'
import type { AppProps } from 'next/app'
export default function App({ Component, pageProps }: AppProps) {
const { user } = pageProps // or from your auth hook
useEffect(() => {
init({ token: 'YOUR_TOKEN_HERE', environment: 'production' })
}, [])
useEffect(() => {
if (user) identify(user.id, { email: user.email, plan: user.plan })
else reset()
}, [user])
return <Component {...pageProps} />
}
Install Tracelit in my Next.js Pages Router project.
Initialize @tracelit/tracker in pages/_app.tsx with:
init({ token: 'YOUR_TOKEN_HERE', environment: 'production' })
Only make minimal edits, show changed files, then add a short verification checklist.