Overview
TheAnalytiq 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
- Only works in React and Next.js (it uses
useEffectanduseRefinternally) - For Next.js App Router, the file using the
Analytiqcomponent must have'use client'at the top - For Vue and Vanilla JS, use
init()from the coreanalytiqpackage 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: