React Native product analytics installation
Contents
Our React Native library enables you to integrate PostHog with your React Native project. For Expo projects, there are no mobile native dependencies outside of supported Expo packages.
Install the PostHog React Native library and its dependencies: PostHog is most easily used via the Once installed, PostHog will automatically start capturing events. You can also manually send events using the Install the package
RequiredConfigure PostHog
RequiredPostHogProvider component. Wrap your app with the provider:Send events
RecommendedusePostHog hook:Next steps
RecommendedResource Description Capturing events Learn how to capture custom events beyond autocapture Identifying users Associate events with specific users Creating insights Build trends, funnels, and retention charts Group analytics Track events at the company or account level
React Native Web and macOS
If you're using React Native Web or React Native macOS, don't use expo-file-system since Web and macOS targets aren't supported. Use @react-native-async-storage/async-storage instead.
Without the PostHogProvider
If you prefer not to use the provider, initialize PostHog in its own file and import the instance:
Then access PostHog by importing your instance:
You can also use this instance with the PostHogProvider: