---
title: "Session Replay"
description: "Enable Session Replay for Android and iOS apps from shared Kotlin Multiplatform code."
url: https://docs.sentry.io/platforms/kotlin/guides/kotlin-multiplatform/session-replay/
---

# Set Up Session Replay | Sentry for Kotlin Multiplatform

[Session Replay](https://docs.sentry.io/product/session-replay.md) helps you understand what a user was doing before and after an error. Configure it in shared Kotlin code to record replays through the Sentry Android and Cocoa SDKs.

## [Prerequisites](https://docs.sentry.io/platforms/kotlin/guides/kotlin-multiplatform/session-replay.md#prerequisites)

Use Sentry Kotlin Multiplatform SDK **0.12.0 or later**. Follow the [installation guide](https://docs.sentry.io/platforms/kotlin/guides/kotlin-multiplatform.md) if you haven't set up the SDK yet.

Session Replay is supported on **Android and iOS**. Android recording requires Android 8 (API level 26) or newer.

##### Compose Multiplatform

Session Replay is not supported for Compose Multiplatform UI. This guide covers KMP apps using native Android and iOS UI.

## [Set Up](https://docs.sentry.io/platforms/kotlin/guides/kotlin-multiplatform/session-replay.md#set-up)

Add Replay sampling to your existing shared initializer:

```kotlin
import io.sentry.kotlin.multiplatform.Sentry

fun initializeSentry() {
    Sentry.init { options ->
        options.dsn = "https://<key>@o<orgId>.ingest.sentry.io/<projectId>"
        options.sessionReplay.sessionSampleRate = 0.1
        options.sessionReplay.onErrorSampleRate = 1.0
    }
}
```

Call the initializer early in each app's lifecycle, as described in [Initialization Options](https://docs.sentry.io/platforms/kotlin/guides/kotlin-multiplatform/initialization-strategies.md#where-to-place-initialization-code).

## [Verify](https://docs.sentry.io/platforms/kotlin/guides/kotlin-multiplatform/session-replay.md#verify)

Temporarily set `sessionSampleRate` to `1.0` to record every session. Launch your app, interact with a few screens, and look for the recording on Sentry's **Replays** page. Inspect text and images in the recording to verify masking. Lower the sample rate before releasing your app.

To test error-only recording, set `sessionSampleRate` to `0.0` and `onErrorSampleRate` to `1.0`, then restart the app. Interact with the app before capturing a test error:

```kotlin
Sentry.captureException(Exception("Test error with Session Replay"))
```

Open the error event in Sentry and check for its linked replay.

## [Sampling](https://docs.sentry.io/platforms/kotlin/guides/kotlin-multiplatform/session-replay.md#sampling)

Both sample rates accept values from `0.0` to `1.0` and default to `null` (disabled):

| Option                            | Behavior                                                                                                                                                                    |
| --------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `sessionReplay.sessionSampleRate` | Samples sessions for recording from the start. For example, `0.1` records approximately 10% of sessions.                                                                    |
| `sessionReplay.onErrorSampleRate` | Samples sessions that weren't selected for full recording when an error occurs. The native SDK buffers up to 30 seconds before the error and continues recording afterward. |

These settings control Replay sampling independently of error-event sampling.

Session duration and lifecycle behavior follow the native SDK. See the [Android](https://docs.sentry.io/platforms/android/session-replay.md) and [iOS](https://docs.sentry.io/platforms/apple/guides/ios/session-replay.md) guides for details.

## [Privacy and Quality](https://docs.sentry.io/platforms/kotlin/guides/kotlin-multiplatform/session-replay.md#privacy-and-quality)

The shared options expose these defaults:

| Option                        | Default                              | Purpose                                                                                                           |
| ----------------------------- | ------------------------------------ | ----------------------------------------------------------------------------------------------------------------- |
| `sessionReplay.maskAllText`   | `true`                               | Masks text in supported UI elements.                                                                              |
| `sessionReplay.maskAllImages` | `true`                               | Masks images in supported UI elements.                                                                            |
| `sessionReplay.quality`       | `SentryReplayOptions.Quality.MEDIUM` | Sets recording quality to `LOW`, `MEDIUM`, or `HIGH`. Higher quality increases data transfer and processing cost. |

Keep masking enabled unless you have reviewed the content your app can display. Masking behavior depends on the native SDK and UI framework. Review the [Android privacy guide](https://docs.sentry.io/platforms/android/session-replay/privacy.md) or [iOS custom redaction guide](https://docs.sentry.io/platforms/apple/guides/ios/session-replay/customredact.md) before customizing it.

To change recording quality, import `io.sentry.kotlin.multiplatform.SentryReplayOptions` and set `options.sessionReplay.quality` inside your initializer.

## [Advanced Configuration](https://docs.sentry.io/platforms/kotlin/guides/kotlin-multiplatform/session-replay.md#advanced-configuration)

For options beyond the shared sampling, masking, and quality settings, use [native platform options](https://docs.sentry.io/platforms/kotlin/guides/kotlin-multiplatform/initialization-strategies.md#native-platform-options) and the native [Android configuration](https://docs.sentry.io/platforms/android/session-replay/configuration.md) or [iOS configuration](https://docs.sentry.io/platforms/apple/guides/ios/session-replay/configuration.md) guide. Available options depend on the native SDK version used by your KMP SDK.

## [Troubleshooting](https://docs.sentry.io/platforms/kotlin/guides/kotlin-multiplatform/session-replay.md#troubleshooting)

If a replay is missing, confirm that sampling is enabled, initialization runs early, and the device uses a supported platform. Use the native guides for platform-specific diagnostics and performance information:

* Android: [Troubleshooting](https://docs.sentry.io/platforms/android/session-replay/troubleshooting.md) and [Performance Overhead](https://docs.sentry.io/platforms/android/session-replay/performance-overhead.md)
* iOS: [Troubleshooting](https://docs.sentry.io/platforms/apple/guides/ios/session-replay/troubleshooting.md) and [Performance Overhead](https://docs.sentry.io/platforms/apple/guides/ios/session-replay/performance-overhead.md)
