About this project

react-fathom is a privacy-first analytics wrapper around Fathom Analytics, designed for React-based applications including web and mobile platforms. It supports automatic pageview tracking on route changes, custom event tracking, goal conversion tracking with monetary values, and offers both programmatic hooks and declarative components for flexible integration. Key features include: - Zero-config setup: wrap your app with FathomProvider and provide a siteId - Automatic pageview tracking for Next.js App Router and Pages Router via NextFathomProviderApp, NextFathomTrackViewApp, and NextFathomTrackViewPages - React Native support through a dedicated /native export using a hidden WebView to load Fathom's tracking script, with offline queuing and React Navigation integration - Full TypeScript support with complete type definitions - Tree-shakeable: only bundle what you use - Default options merging: set app-wide defaults in FathomProvider that automatically merge into all tracking calls - Nested provider support: child providers can override parent defaults - Custom client implementation: provide a FathomClient interface for React Native, testing mocks, or server-side rendering scenarios - Convenience hooks: useTrackOnMount, useTrackOnClick, and useTrackOnVisible for common tracking patterns - Declarative components: TrackPageview, TrackClick, and TrackVisible for JSX-based tracking - Support for custom Fathom domains - App state tracking in React Native (foreground/background events) The package requires fathom-client as a peer dependency and works with React >= 16.8, Next.js >= 10.0.0, and React Native >= 0.60.0. There are no cookies required by Fathom itself, making it GDPR, CCPA, and PECR compliant out of the box without consent banners.