@molecule/app-analytics-react

Feature · analytics · App (browser) · v1.1.1 · Apache-2.0

React bindings for @molecule/app-analytics (route listener)

npm install @molecule/app-analytics-react

npm · Source on GitHub

How it works

@molecule/app-analytics-react is a ready-made analytics feature for the app (browser) side. It composes the core interfaces it needs, so it works with whichever providers your app has bonded.

import { AnalyticsRouteListener } from '@molecule/app-analytics-react'

// Mount once beside the app's routed view, inside the routing bond's shell.
export function App() {
  return <AnalyticsRouteListener />
}

Works with: @molecule/app-analytics, @molecule/app-react

Reference

React bindings for @molecule/app-analytics.

Provides ready-made React components that consume the wired analytics bond. Currently exports AnalyticsRouteListener, a render-free component that fires a page event on every client-side route change.

Mount AnalyticsRouteListener once inside the app's router subtree — it listens for useLocation() changes and forwards each pathname / search change to the wired analytics bond's page(). The routing bond mounts RouterProvider, so the listener renders beneath it and under every routing bond.

Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit src/index.ts JSDoc, not this file.

Quick Start

import { AnalyticsRouteListener } from '@molecule/app-analytics-react'

// Mount once beside the app's routed view, inside the routing bond's shell.
export function App() {
  return <AnalyticsRouteListener />
}

Type

feature

Installation

npm install @molecule/app-analytics-react @molecule/app-analytics @molecule/app-react react
npm install -D @types/react

API

Functions

AnalyticsRouteListener()

Records a page_view on client-side route changes.

Mount once inside the app's router subtree. On every pathname / search change, dispatches a page event through the wired analytics bond. Renders nothing.

function AnalyticsRouteListener(): null

Returns: Always null — this component renders nothing.

Injection Notes

Requirements

Peer dependencies:

  • @molecule/app-analytics ^1.0.1
  • @molecule/app-react ^4.12.0 || ^5.0.0
  • react ^18.0.0 || ^19.0.0

Runtime Dependencies

  • @molecule/app-analytics
  • @molecule/app-react
  • react