Compose Multiplatform and Jetpack Compose
Compose Multiplatform is a cross-platform UI toolkit developed by JetBrains. It extends Google's Jetpack Compose toolkit for Android by supporting for additional platforms.
Compose Multiplatform makes compose APIs available from common Kotlin code, allowing you to write shared compose UI code that can run on Android, iOS, desktop, and web.
Compose Multiplatform | Jetpack Compose | |
---|---|---|
Platforms | Android, iOS, desktop, web | Android |
Supported by | JetBrains |
As Compose Multiplatform is based on Jetpack Compose, using these frameworks is a very similar experience. Both are powered by the Compose compiler and runtime. They use the same core concepts and the same APIs for building UI, including @Composable
functions, state handling APIs like remember
, UI components such as Row
and Column
, modifiers, animation APIs, and so on. This means that you can reuse existing knowledge of Jetpack Compose in Compose Multiplatform, and you can learn from almost any Jetpack Compose material, including Google's official documentation.
Naturally, Compose Multiplatform has platform-specific features and considerations:
The Android-only components page lists APIs that are closely tied to the Android platform and are therefore not available from common Compose Multiplatform code.
Some platform-specific APIs, such as window handling APIs for desktop or the UIKit compatibility APIs for iOS, are only available on their respective platforms.
Here's an overview of the availability of popular components and APIs:
Compose Multiplatform | Jetpack Compose | |
---|---|---|
Yes | Yes | |
Yes | Yes | |
Yes | Yes | |
Yes | Yes | |
Yes, except for | Yes | |
Yes, except for | Yes | |
Yes | Yes | |
Yes | ||
Yes | ||
Yes | ||
Resources | Compose Multiplatform resources library using the | Android resource system using the |
No | Yes | |
Third-party libraries for UI components, navigation, architecture, and more | Jetpack Compose and Compose Multiplatform libraries |
Technical details
Compose Multiplatform builds on code and releases published by Google. While Google's focus is Jetpack Compose for Android, there is close collaboration between Google and JetBrains to enable Compose Multiplatform.
Jetpack includes first-party libraries such as Foundation and Material, which Google publishes for Android. To make the APIs provided by these libraries available from common code, JetBrains maintains multiplatform versions of these libraries, which are published for targets other than Android.
When you build your Compose Multiplatform application for Android, you use the Jetpack Compose artifacts published by Google. For example, if you add compose.material3
to your dependencies, your project will use androidx.compose.material3:material3
in the Android target, and org.jetbrains.compose.material3:material3
in other targets. This is done automatically, based on Gradle Module Metadata in the multiplatform artifacts.
Libraries for Compose Multiplatform
By using Compose Multiplatform, you can publish your libraries that use compose APIs as Kotlin Multiplatform libraries. This makes them available for use from common Kotlin code, targeting multiple platforms.
So if you're building a new library with compose APIs, consider taking advantage of that and building it as a multiplatform library using Compose Multiplatform. If you've already built a Jetpack Compose library for Android, consider making that library multiplatform. There are already many Compose Multiplatform libraries available in the ecosystem.
When a library is published with Compose Multiplatform, apps that only use Jetpack Compose are still able to consume it seamlessly; they simply use the Android artifacts of the library.
What's next
Read more about Compose Multiplatform implementation for the following components: