expo-facebook-analytics
v1.1.2
Published
High-performance Facebook Analytics for React Native using Nitro Modules
Maintainers
Readme
expo-facebook-analytics
High-performance Facebook Analytics for React Native using Nitro Modules.
📖 Documentation · 🧪 Example app
Minimal by design. This library wraps only the Facebook App Events / Analytics APIs — event logging, user identity, and device identifiers. It is not a full Facebook SDK (no Login, Sharing, Graph API, or Gaming). If you only need analytics and conversion tracking, that's the point: a tiny, fast surface area built on a zero-overhead Nitro/JSI bridge to the native SDK.
Installation
npx expo install expo-facebook-analytics react-native-nitro-modulesAdd the config plugin to your app.json:
{
"expo": {
"plugins": [
[
"expo-facebook-analytics",
{
"appID": "YOUR_FACEBOOK_APP_ID",
"clientToken": "YOUR_FACEBOOK_CLIENT_TOKEN"
}
]
]
}
}The module ships native code, so it requires a development build — it can't run in Expo Go.
Quick start
import { logEvent, logPurchase, AppEvents } from 'expo-facebook-analytics';
logEvent(AppEvents.ViewedContent);
logEvent(AppEvents.AddedToCart, { product: 'sku-123' });
logPurchase(29.99, 'USD');For deferred (consent-gated) initialization, set isAutoInitEnabled: false in the
plugin and call initialize() yourself; with autoLogAppEventsEnabled: false, also
call activateApp() so Meta still receives the install event. Enable the Facebook
SDK's native logging with setLoggingEnabled(true). See the documentation for the full API.
See the documentation for the full API, config-plugin options, manual initialization, and predefined constants.
Requirements
| Tool | Version |
| ---------------------------- | ------- |
| Expo SDK | 56+ |
| React Native | 0.85+ |
| react-native-nitro-modules | 0.35.9+ |
| iOS deployment target | 16.4+ |
| Android minSdkVersion | 24+ |
Native SDKs: Facebook iOS/Android SDK 18. Requires the React Native New Architecture (default in SDK 56).
Contributing
bun install # install dependencies
bun run nitrogen # regenerate native bindings
bun run prepare # build the library
bun test # run tests
bun run check # lint & formatTo run the example app, see example/.
License
MIT
