For the complete documentation index, see llms.txt. This page is also available as Markdown.

React Native

The Hackle React Native SDK supports React 17.0.1 and above, and React Native 0.64.1 and above.

The React Native SDK is built on top of the Android SDK and iOS SDK, and supports the following OS versions.

  • Android API 24 (7.0 NOUGAT) and above

  • iOS 13 and above

OS Support by React Native SDK Version
Hackle React Native SDK Version
Supported OS

Below 3.31.0

  • Android API 16 and above

  • iOS 10 and above

3.31.0 and above, below 3.36.0

  • Android API 16 and above

  • iOS 13 and above

3.36.0 and above, below 4.0.0

  • Android API 21 and above

  • iOS 13 and above

4.0.0 and above

  • Android API 24 and above

  • iOS 13 and above

Add Dependency

npm install --save @hackler/react-native-sdk
yarn add @hackler/react-native-sdk

iOS

cd ios
pod install

Adding Dependency with Expo

Expo is supported in React Native SDK version 3.17.0 and above.

When using Expo, you do not need to run link or pod install.

Android Configuration

Add the following code to your Application class under the onCreate function.

SDK Initialization

To use the SDK, you must pass the SDK Key to createInstance() to create a HackleReactNativeSDKClient and pass it to the HackleProvider that wraps your React application.

At initialization, the SDK fetches necessary data from the Hackle server and stores it. This typically takes only a few milliseconds. Rendering begins immediately after synchronization is complete.

Injecting User at Initialization

This feature is supported in React Native SDK version 3.31.0 and above.

You can initialize the SDK with user information included.

  • If no user information is provided, the user information stored in local storage is used.

  • If user information is provided, the user information stored in local storage is not used.

  • If no user is injected and there is no user information in local storage, a user with the Hackle Device ID as the device id is used.

You can freely update user information after SDK initialization using the user information setter functions.

SDK Initialization Config

You can initialize the SDK with configuration options.

Option
Description
Default
Supported Version

exposureEventDedupIntervalMillis

Removes duplicate exposure events for the same A/B Test or Feature Flag distribution result triggered by the same user consecutively. Minimum: 1000 (1 second) Maximum: 3600000 (1 hour)

-1 (no dedup)

3.3.1+

debug

Prints logs for all features to the console and sends events immediately.

false

3.4.1+

pollingIntervalMillis

Periodically updates the configuration set in the Dashboard. Minimum: 60000 (60 seconds)

-1 (no periodic update)

3.6.0+

automaticAppLifecycleTracking

Whether to enable automatic app start/end tracking

true

3.30.0+

automaticScreenTracking

Whether to enable automatic screen tracking

true

3.30.0+

sessionPolicy

Configures session persistence and expiration conditions.

persistCondition: alwaysNewSession,

timeoutMillis: 1800000 (30 min)

3.32.0+

optOutTracking

Whether opt-out is enabled. When enabled, all event sending is stopped.

false

3.32.0+

evaluationMode

Configures the evaluation mode.

"local"

4.0.0+

sessionTimeoutMillis (deprecated)

Sets the session expiration time. Please use sessionPolicy instead.

1800000 (30 min)

3.11.0+

Evaluation Mode Configuration

You can choose whether the SDK performs evaluation itself or fetches results that the Hackle server has already evaluated. If not configured, the default value "local" (local evaluation) is used.

Session Policy Configuration

You can configure session persistence and expiration conditions using the session policy.

Refreshing Dashboard Configuration

You can explicitly refresh the Dashboard configuration.

Last updated