← All @molecule/* packages · App templates
@molecule/app-analytics-reactFeature · analytics · App (browser) · v1.0.1 · Apache-2.0
React bindings for @molecule/app-analytics (route listener)
npm install @molecule/app-analytics-react@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'
import { BrowserRouter, Routes, Route } from 'react-router'
export function App() {
return (
<BrowserRouter>
<AnalyticsRouteListener />
<Routes>
<Route path="/" element={<Home />} />
</Routes>
</BrowserRouter>
)
}Works with: @molecule/app-analytics
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().
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>
)
}
feature
npm install @molecule/app-analytics-react @molecule/app-analytics react react-router
npm install -D @types/react
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(): null
Returns: Always null — this component renders nothing.
Peer dependencies:
@molecule/app-analytics ^1.0.1react ^18.0.0 || ^19.0.0react-router ^7.0.0 || ^8.0.0@molecule/app-analyticsreactreact-router