@molecule/app-analytics-react
v1.0.2
Published
React bindings for @molecule/app-analytics (route listener, hooks)
Readme
@molecule/app-analytics-react
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.tsJSDoc, not this file.
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 a BrowserRouter
subtree — it listens for useLocation() changes and forwards each
pathname / search change to the wired analytics bond's page().
Quick Start
import { AnalyticsRouteListener } from '@molecule/app-analytics-react'
import { BrowserRouter, Routes, Route } from 'react-router'
export function App() {
return (
<BrowserRouter>
<AnalyticsRouteListener />
<Routes>
<Route path="/" element={<Home />} />
</Routes>
</BrowserRouter>
)
}Type
feature
Installation
npm install @molecule/app-analytics-react @molecule/app-analytics react react-router
npm install -D @types/reactAPI
Functions
AnalyticsRouteListener()
Records a page_view on client-side route changes.
Mount once inside a BrowserRouter subtree. On every pathname /
search change, dispatches a page event through the wired analytics
bond. Renders nothing.
function AnalyticsRouteListener(): nullReturns: Always null — this component renders nothing.
Injection Notes
Requirements
Peer dependencies:
@molecule/app-analytics^1.0.1react^18.0.0 || ^19.0.0react-router^7.0.0 || ^8.0.0
Runtime Dependencies
@molecule/app-analyticsreactreact-router
