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
};

❗️

Known Issue with React Native 0.76

Issue Description: Some users have reported UI freezes when using LogRocket with the React Native New Architecture, which is the default on versions 0.76 and above.

Status: We are investigating an issue in which touch handlers cause UI freezes on iOS. While we work on a fix for this issue, there are two workarounds.

  1. Disable the new architecture

If your app doesn't depend on any New Architecture-specific features, LogRocket will work with touch tracking enabled if the app is compiled with the legacy React Native architecture. Add the following line to the top of the main scope in ios/Podfile.

ENV['RCT_NEW_ARCH_ENABLED'] = '0'
  1. Disable touch tracking

This option will retain the New Architecture but disables LogRocket touch tracking. When initializing LogRocket from your app, pass the following config option.

LogRocket.init('<app_slug>', {
    // ...config options
    registerTouchHandlers: false
});

We apologize for any inconvenience and appreciate your patience as we work towards a resolution.