Skip to main content

Overview

The Analytiq component is the core initialization component for React and Next.js. It safely calls init() once when your app mounts and is fully compatible with React 18 Strict Mode. You should never use this component directly in your pages. Instead, wrap it inside your analytics.jsx bridge file alongside your Auth hook, then add AnalyticsProvider at the root of your application.

Import

Usage (inside your analytics.jsx)

src/analytics.jsx

Props

What it does

Important Rules

Place the Analytiq component in only one place — inside your analytics.jsx provider file. Mounting it in multiple components will trigger a double-init warning.
  • Only works in React and Next.js (it uses useEffect and useRef internally)
  • For Next.js App Router, the file using the Analytiq component must have 'use client' at the top
  • For Vue and Vanilla JS, use init() from the core analytiq package instead

TypeScript

Other exports from analytiq/react

The analytiq/react package also re-exports all core tracking functions so you can import everything from one place inside your analytics.jsx file: