React Native session replay installation

  1. Install the packages

    Required

    Install the PostHog React Native library, its dependencies, and the session replay plugin:

    npx expo install posthog-react-native expo-file-system expo-application expo-device expo-localization posthog-react-native-session-replay
    SDK version

    Session replay requires PostHog React Native SDK version 3.2.0 or higher. We recommend always using the latest version.

  2. Enable session recordings in project settings

    Required

    Go to your PostHog Project Settings and enable Record user sessions. Session recordings will not work without this setting enabled.

  3. Configure PostHog with session replay

    Required

    Add enableSessionReplay: true to your PostHog configuration. Here are all the available options:

    App.tsx
    import { PostHogProvider } from 'posthog-react-native'
    export function MyApp() {
    return (
    <PostHogProvider
    apiKey="<ph_project_api_key>"
    options={{
    host: "https://us.i.posthog.com",
    // Enable session recording. Requires enabling in your project settings as well.
    // Default is false.
    enableSessionReplay: true,
    sessionReplayConfig: {
    // Whether text inputs are masked. Default is true.
    // Password inputs are always masked regardless
    maskAllTextInputs: true,
    // Whether images are masked. Default is true.
    maskAllImages: true,
    // Capture logs automatically. Default is true.
    // Android only (Native Logcat only)
    captureLog: true,
    // Whether network requests are captured in recordings. Default is true
    // Only metric-like data like speed, size, and response code are captured.
    // No data is captured from the request or response body.
    // iOS only
    captureNetworkTelemetry: true,
    // Throttling delay used to reduce the number of snapshots captured
    // and reduce performance impact. Default is 1000ms
    throttleDelayMs: 1000,
    },
    }}
    >
    <RestOfApp />
    </PostHogProvider>
    )
    }

    For more configuration options, see the React Native session replay docs.

    Requirements

    Requires Android API 26+ and iOS 13+. Expo Go is not supported - use a development build. Session replay is only supported on Android and iOS platforms.

  4. Watch session recordings

    Recommended

    Visit your site or app and interact with it for at least 10 seconds to generate a recording. Navigate between pages, click buttons, and fill out forms to capture meaningful interactions.

    Watch your first recording →

  5. Next steps

    Recommended

    Now that you're recording sessions, continue with the resources below to learn what else Session Replay enables within the PostHog platform.

    ResourceDescription
    Watching recordingsHow to find and watch session recordings
    Privacy controlsHow to mask sensitive data in recordings
    Network recordingHow to capture network requests in recordings
    Console log recordingHow to capture console logs in recordings
    More tutorialsOther real-world examples and use cases

Community questions

Was this page useful?

Questions about this page? or post a community question.