Initialize SDK

Initialize LogRocket and start recording sessions

Call init() with your appID to configure and start LogRocket. You can find your appID on https://app.logrocket.com under Settings > Project Setup.

Adding the SDK

Our React Native package is available on NPM. New releases of the LogRocket Native SDKs are catalogued on our Mobile SDK Changelog.

npm install --save @logrocket/react-native

Preparing Android

In order for our Android Native SDK to be added to the application a small change must be made to the android/build.gradle file: find the repositories block and add our maven repository:

allprojects {
  repositories {
    // Add this declaration to any existing repositories block. Do not remove any existing entries in the block.
    maven { url "https://storage.googleapis.com/logrocket-maven/" }
  }
}

Preparing iOS

Our iOS Native SDK is provided through CocoaPods and must be added to the iOS project via pod install, or using the pod-install helper.

First update your Podfile to use the correct iOS version with platform :ios, '12.0' (or greater) and then run the following:

npx pod-install

Initializing the SDK

Initializing the SDK is as simple as importing the package and running the initialization method. A good place to initialize the SDK is in a useEffect hook in your top-level Application component.

Replace <APP_SLUG> with your LogRocket application slug, located in our dashboard's quick start guides.

import React, { useEffect } from 'react';
import LogRocket from '@logrocket/react-native';

const App = () => {
  useEffect(() => {
    LogRocket.init('<APP_SLUG>');
  }, []);
  // Your application entry
};