---
title: "Compose Multiplatform"
description: "Learn how to integrate Sentry's Kotlin Multiplatform SDK into your Compose Multiplatform project for cross-platform error tracking."
url: https://docs.sentry.io/platforms/kotlin/guides/compose-multiplatform/
---

# Compose Multiplatform | Sentry for Compose Multiplatform

##### Experimental Support

While Sentry's Kotlin Multiplatform SDK works in Compose Multiplatform (CMP) projects, it isn't natively supported or fully tested for CMP. Some features may behave unexpectedly or provide incomplete data. Use with caution in production environments and report any issues you encounter.

## [Overview](https://docs.sentry.io/platforms/kotlin/guides/compose-multiplatform.md#overview)

**Compose Multiplatform** is JetBrains' declarative UI framework that allows you to build native user interfaces for desktop, web, and mobile platforms using a single Kotlin codebase. It extends Jetpack Compose beyond Android to create multiplatform applications.

You need to use the [Sentry Kotlin Multiplatform SDK](https://docs.sentry.io/platforms/kotlin/guides/kotlin-multiplatform.md) which provides error tracking across multiple Kotlin targets. While the SDK functions in Compose Multiplatform projects use the same APIs as pure KMP setups, it's important to note a few differences:

* **Experimental support**: The KMP SDK works in CMP projects and currently supports capturing crashes and errors as well as other basic features that are available through the Sentry KMP SDK.
* **Not CMP-native**: No specific CMP optimizations or testing.
* **Untested edge cases**: Some platform-specific behaviors may be incomplete.

## [Installation](https://docs.sentry.io/platforms/kotlin/guides/compose-multiplatform.md#installation)

Sentry captures data by using an SDK within your application's runtime.

To install the Kotlin Multiplatform SDK in your Compose Multiplatform project, you need to add the following to your `build.gradle.kts` file in your shared module:

`composeApp/build.gradle.kts`

```kotlin
plugins {
  id("io.sentry.kotlin.multiplatform.gradle") version "0.25.0"
}
```

The plugin does the following:

* Automatically installs the Sentry KMP dependency to `commonMain`.
* If you use the Kotlin Cocoapods plugin, it installs the Sentry Cocoa dependency.
* If you use Swift Package Manager, it sets up linking to the Sentry Cocoa framework.

If you use Swift Package Manager instead of Cocoapods, you need to install the [Sentry Cocoa dependency with Swift Package Manager](https://docs.sentry.io/platforms/apple/install/swift-package-manager.md) in your Xcode project first before executing the Gradle plugin.

Make sure that you install the Sentry Cocoa SDK version compatible with the corresponding Sentry Kotlin Multiplatform SDK version. You can find the compatible versions in the [Sentry Kotlin Multiplatform SDK README](https://github.com/getsentry/sentry-kotlin-multiplatform?tab=readme-ov-file#cocoa-sdk-version-compatibility-table).

## [Configure](https://docs.sentry.io/platforms/kotlin/guides/compose-multiplatform.md#configure)

Configuration should happen as early as possible in your application's lifecycle to ensure a working instrumentation. Configure with the following steps:

1. Add a function to initialize Sentry to your shared module (`commonMain`).
2. Call the function in your iOS and Android app modules.

`SentrySetup.kt`

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

fun initializeSentry() {
  Sentry.init { options ->
    options.dsn = "___PUBLIC_DSN___"
    // Adds request headers and IP for users, for more info visit:
    // https://docs.sentry.io/platforms/kotlin/guides/kotlin-multiplatform/data-management/data-collected/
    options.sendDefaultPii = true
  }
}
```

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

This snippet includes an intentional error, so you can test that everything is working as soon as you set it up.

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

// Add the following button to your Compose UI and click it to trigger an error
Button(onClick = {
    try {
        throw Exception("Sentry works!")
    } catch (e: Exception) {
        Sentry.captureException(e)
    }
}) {
    Text("Send an error to Sentry")
}
```

## [Supported Platforms](https://docs.sentry.io/platforms/kotlin/guides/compose-multiplatform.md#supported-platforms)

For a complete list of supported platforms and target presets, see the [Kotlin Multiplatform features documentation](https://docs.sentry.io/platforms/kotlin/guides/kotlin-multiplatform/features.md#supported-platforms).

## [Debug Symbols](https://docs.sentry.io/platforms/kotlin/guides/compose-multiplatform.md#debug-symbols)

Error stack traces in your app might appear unreadable or obfuscated, making it hard to debug issues. To make stack traces clear and human-readable in Sentry, you need to upload your app's debug symbols.

### [Android](https://docs.sentry.io/platforms/kotlin/guides/compose-multiplatform.md#android)

For Android applications, you need to manually upload ProGuard mapping files using the `sentry-cli`. Follow the [ProGuard Mapping Upload guide](https://docs.sentry.io/cli/dif.md#proguard-mapping-upload) for detailed instructions.

### [iOS](https://docs.sentry.io/platforms/kotlin/guides/compose-multiplatform.md#ios)

For iOS applications, follow the [Uploading Debug Symbols guide](https://docs.sentry.io/platforms/apple/guides/ios/dsym.md) to set up debug symbols upload.

## [Next Steps](https://docs.sentry.io/platforms/kotlin/guides/compose-multiplatform.md#next-steps)

* Explore [practical guides](https://docs.sentry.io/guides.md) on what to monitor, log, track, and investigate after setup
