CleverTap React Native SDK
raw JSON → 4.1.0 verified Fri May 01 auth: no javascript
CleverTap React Native SDK v4.1.0 provides a native bridge to CleverTap's mobile customer engagement and analytics platform for React Native apps (requires react-native >=0.65.0). The SDK supports push notifications, in-app notifications (including Picture-in-Picture, GIF, and video), user segmentation, event tracking, and A/B testing. It ships with TypeScript definitions and supports New Architecture on React Native >=0.71. Releases typically align with CleverTap’s iOS and Android SDKs every few months. Key differentiators: native performance, deep integration with CleverTap's dashboard, and support for rich media in-app templates.
Common errors
error Error: `CleverTap` is undefined when using `import { CleverTap } from 'clevertap-react-native'` ↓
cause Wrong import syntax: named import instead of default import.
fix
Use
import CleverTap from 'clevertap-react-native'. error TypeError: CleverTap.recordEvent is not a function ↓
cause Importing the module incorrectly or using an outdated version of the SDK.
fix
Ensure you are using default import and the SDK version is >=3.0.0.
error Native Module: CleverTap is undefined (React Native) ↓
cause Native module not linked properly (for RN <0.60) or pods not installed (iOS).
fix
For RN <0.60, run
react-native link clevertap-react-native. For iOS, ensure cd ios && pod install. For New Architecture, ensure enabled. error Invariant Violation: `onUserLogin` is not a function ↓
cause Using an outdated callback pattern from older SDK versions.
fix
Use
CleverTap.onUserLogin({...}) with a profile object. Update SDK to >=3.0.0. Warnings
breaking v4.0.0 requires React Native >=0.65.0 and drops support for older versions. ↓
fix Update react-native to >=0.65.0. See the version support table in README.
gotcha Default import only: using named import `{ CleverTap }` results in undefined. ↓
fix Use `import CleverTap from 'clevertap-react-native'`.
deprecated The `onUserLogin` callback signature changed in v3.0.0; old callback style no longer works. ↓
fix Migrate to new signature: `CleverTap.onUserLogin(profileObject)`.
gotcha iOS Push Templates SDK requires additional setup: follow docs/iospushtemplates.md. ↓
fix Integrate push templates as per the documentation.
gotcha Android: for Huawei push, changed integration steps since v3.4.0. See guide. ↓
fix Refer to the CleverTap Huawei Push Integration guide.
Install
npm install clevertap-react-native yarn add clevertap-react-native pnpm add clevertap-react-native Imports
- default import wrong
const CleverTap = require('clevertap-react-native');correctimport CleverTap from 'clevertap-react-native'; - CleverTap wrong
import { CleverTap } from 'clevertap-react-native';correctimport CleverTap from 'clevertap-react-native'; - registerForPush wrong
CleverTap.registerForPush()correctimport CleverTap from 'clevertap-react-native'; CleverTap.registerForPush(); - onUserLogin wrong
CleverTap.onUserLogin(...)correctimport CleverTap from 'clevertap-react-native'; CleverTap.onUserLogin({...});
Quickstart
import CleverTap from 'clevertap-react-native';
// Initialize (auto if installed correctly)
// Record an event
CleverTap.recordEvent('Product Viewed', {
'Product Name': 'Casio Watch',
'Category': 'Mens Accessories'
});
// Set user profile
CleverTap.onUserLogin({
'Name': 'John Doe',
'Email': 'john.doe@example.com',
'Phone': '+14155551234'
});
// Register for push notifications
CleverTap.registerForPush();
// Fetch in-app notifications
CleverTap.recordEvent('App Launched');