Skip to main content
Mixpanel’s React Native Session Replay SDK enables you to capture and analyze user interactions in your mobile applications. Built as a Turbo Module for React Native’s New Architecture, it provides native implementations for both iOS and Android with a unified JavaScript API.

Features

  • 📱 Cross-Platform Support - Unified API for iOS and Android
  • 🎥 Session Recording - Capture user interactions and screen recordings
  • 🔒 Privacy-First - Built-in data masking for sensitive information
  • ⚡ High Performance - Native implementation with minimal JavaScript bridge overhead
  • 🎯 Selective Recording - Configurable sampling rates and recording controls
  • 🚀 New Architecture Ready - Built as a Turbo Module with full type safety
  • 🛡️ Granular Privacy Controls - Auto-masking and manual masking via wrapper components

Requirements

  • React Native >= 0.70
  • iOS >= 13.0
  • Android API Level >= 21
  • New Architecture support (backward compatible with old architecture)

Installation

or

Platform Setup

iOS

The SDK dependencies are automatically added via CocoaPods. Your project must target iOS 13 or later.

Android

Dependencies are automatically added through Gradle. Requirements:
  • Minimum Android SDK 21+
  • Kotlin support enabled

Quick Start

Here’s a minimal example to get started with Session Replay:

Data Residency

Available in React Native Session Replay SDK version 1.3.0 and later.
If your Mixpanel project lives in the EU or India data center, or you route all Mixpanel traffic through a self-hosted proxy, set serverURL on MPSessionReplayConfig. The SDK exposes a MPDataResidency constant set with the managed region URLs so you don’t have to hardcode them.
RegionMPDataResidency constantURL
US (default)MPDataResidency.UShttps://api.mixpanel.com
EUMPDataResidency.EUhttps://api-eu.mixpanel.com
IndiaMPDataResidency.INhttps://api-in.mixpanel.com
Example Usage
You can also pass any fully-qualified HTTPS URL — useful when routing replay traffic through a self-hosted proxy:
Learn more about EU Data Residency and India Data Residency.

Configuration

The MPSessionReplayConfig class provides comprehensive control over session replay behavior:

Configuration Options

OptionTypeDefaultDescription
wifiOnlybooleantrueOnly transmit recordings over WiFi
autoStartRecordingbooleantrueAutomatically start recording on initialization
recordingSessionsPercentnumber100Percentage of sessions to record (0-100)
autoMaskedViewsMPSessionReplayMask[]All typesView types to automatically mask
flushIntervalnumber10Interval in seconds to flush recordings
enableLoggingbooleanfalseEnable debug logging
remoteSettingsModeMPSessionReplayRemoteSettingsModeDisabledSetting for handling remote configuration during SDK initialization. Can be Disabled/ Fallback/ Strict.

Auto-Masked View Types

The MPSessionReplayMask enum defines view types that can be automatically masked:
Example - Custom Auto-Masking:

API Reference

initialize

Initialize the Session Replay SDK with your configuration.
Parameters:
  • token (required) - Your Mixpanel project token
  • distinctId (required) - User identifier for the session
  • config (required) - Session replay configuration
Validation:
  • Token must be a non-empty string
  • distinctId must be a non-empty string
  • recordingSessionsPercent must be between 0 and 100
Example:

startRecording

Start recording user interactions.
Example:

stopRecording

Stop recording user interactions.
Example:

isRecording

Check if session recording is currently active.
Returns: Boolean indicating recording status Example:

identify

Update the user identifier for the current recording session.
Parameters:
  • distinctId (required) - New user identifier
Example:

Remote Configuration

Available in React Native Session Replay SDK version 1.2.0 and later. Requires a paid Session Replay add-on.
You can set the remote_settings_mode for your project in Mixpanel under Settings > Organization Settings > Session Replay. Using this, you can quickly set SDK options remotely without needing to update your app. This allows you to adjust recording settings, such as sampling rates, on the fly based on your needs. Three modes are available:
  • Disabled: Do not use remote configuration and proceed to use the hardcoded initial options provided by the user during initialization. This is the default behavior.
  • Fallback: Attempt to retrieve remote configuration and proceed with those settings. If there is failure or timeout (500 ms), we will use the previously cached remote settings (if one exists from the last successful fetch). If no existing remote settings are cached, we will use the values from the SDK initialization config.
  • Strict: Requires successful remote configuration fetch for SDK initialization. If there is failure or timeout (500 ms), SDK initialization will fail and the Session Replay features will be unavailable for that app launch.
You can use this setting to quickly update and adjust configurations to your liking. List of currently supported remote settings:
  • recordingSessionsPercent
Settings not yet supported by remote configuration will use the value provided during initialization, or the default value if none was provided

Privacy & Data Masking

Session Replay provides two approaches to protect sensitive data: automatic masking and manual masking.

Automatic Masking

Configure which view types are automatically masked during initialization:
Default Behavior: All view types are masked by default for maximum privacy.

Manual Masking with MPSessionReplayView

Use the MPSessionReplayView wrapper component for granular control over what gets masked:

Complete Masking Example