Moments API Module (now Context API)
Learn how to install the Tealium Context API module for React Native.
Moments API has been renamed to Context API. For full product documentation, see About Context API.
How it works
Tealium mobile libraries are integrated into your React Native application using one of the following methods:
- NPM package (Recommended)
- Manually with GitHub
After you install the Context API module, import the necessary classes into your app and initialize the Context API module.
Requirements
The Tealium Context API module requires the following:
- Access to your native build environments
- Tealium for React Native 2.2.0 or later
- React Native 0.63 or later and tools
- Tealium iQ Mobile Profile
- Android Studio or Xcode
- Tealium for Android or Tealium for iOS
Install (NPM/YARN)
To install the Tealium Context API module for React Native with NPM:
- Follow the installation instructions for the main
tealium-react-nativelibrary installation. Ensure that you have installed at least version 2.2.0 or later. - Go to the root directory of your React Native project.
- Download and install the
tealium-react-native-moments-apipackage with the following command:yarn install tealium-react-native-moments-api
JavaScript
To import the relevant classes into your app, add the following code:
import TealiumMomentsApi from 'tealium-react-native-moments-api';
import { TealiumMomentsApiConfig, MomentsApiRegion} from 'tealium-react-native-moments-api/common';
Initialize
Configure the Context API module prior to initializing the main Tealium React Native integration. Use TealiumMomentsApiConfig parameters to enable settings as needed.
let momentsApiConfig: TealiumMomentsApiConfig = {
region: MomentsApiRegion.UsEast, // Setting a region is mandatory. The Context API module will not initialize if it is missing.
referrer: "https://tealium.com" // Optional - specify a referrer URL. This URL must match the "Domain Allow List" in the Tealium UI, or the Context API will not return any data.
}
TealiumMomentsApi.configure(momentsApiConfig);
API Reference
After the Context API Module and the main Tealium React Native integration have both been initialized, you can retrieve engine data by ID.
fetchEngineResponse(engineId, callback)
Retrieves the engine response for the given engine ID.
TealiumMomentsApi.fetchEngineResponse(
id,
value => {
console.log("Engine Response data: " + JSON.stringify(value))
}
);
This page was last updated: September 14, 2026