Enable Compose Multiplatform
Add the plugin and your first shared composable.
Enable Compose Multiplatform is a free Kotlin Multiplatform Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Kotlin Multiplatform Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
One UI, Every Screen
Compose Multiplatform lets you describe your UI once in Kotlin and render it on Android, iOS and desktop. The same screen code runs everywhere. 🎉
Built on Jetpack Compose
If you know Jetpack Compose, you already know most of this. Compose Multiplatform brings that same declarative toolkit to every target you support.
Add the Compose Plugin
You enable it by adding the Compose Gradle plugin alongside the Kotlin Multiplatform plugin in your shared module. That unlocks the composable APIs.
plugins {
kotlin("multiplatform")
id("org.jetbrains.compose")
}Pull In the Compose BOM
The Compose dependencies live behind a single accessor. You add the runtime, foundation and material libraries from the compose extension so versions stay aligned.
kotlin {
sourceSets {
commonMain.dependencies {
implementation(compose.material3)
}
}
}Your First Shared Composable
A composable is just a Kotlin function marked with @Composable. Put it in commonMain and it becomes available to every platform at once.
import androidx.compose.runtime.Composable
import androidx.compose.material3.Text
@Composable
fun Greeting(name: String) {
Text("Hello, " + name)
}A Root App Composable
Most projects expose one top-level App composable in shared code. Each platform simply calls into it, so the whole UI tree is shared.
@Composable
fun App() {
Greeting("KMP")
}Material Theming Comes Along
Compose Multiplatform ships Material components and theming, so buttons, text fields and colors look consistent across platforms out of the box.
@Composable
fun App() {
MaterialTheme {
Greeting("KMP")
}
}Android Hosts It Natively
On Android you mount the shared App inside an Activity using setContent, exactly like a normal Compose app. Nothing special is required.
class MainActivity : ComponentActivity() {
override fun onCreate(b: Bundle?) {
super.onCreate(b)
setContent { App() }
}
}iOS and Desktop Plug In Too
iOS and desktop each have a tiny entry point that hosts the same App composable. You write the screen once and host it from every target.
Live Previews Still Work
You keep fast iteration with @Preview in your IDE, so you see your shared composable render without launching a full device build each time.
What This Unlocks
With Compose enabled, your UI joins your logic in shared code. The result is one codebase driving pixel-identical screens on phones and desktops.
Quick Check
Where does a shared composable belong?
Recap: Compose Everywhere
You enabled the Compose plugin, wrote a shared composable in commonMain, wrapped it in MaterialTheme and saw how each platform hosts the same App. One UI, every screen. 🚀
Frequently asked questions
Is the “Enable Compose Multiplatform” lesson free?
Yes — the full text of “Enable Compose Multiplatform” is free to read here on the web, and the Kotlin Multiplatform Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Kotlin Multiplatform Academy course, upgrade to CoddyKit PRO.
What will I learn in “Enable Compose Multiplatform”?
Add the plugin and your first shared composable. You practise Kotlin Multiplatform Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Kotlin Multiplatform Academy?
No prior experience is required. Kotlin Multiplatform Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Enable Compose Multiplatform” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Kotlin Multiplatform Academy lesson?
Yes. Every Kotlin Multiplatform Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Enable Compose Multiplatform
- Layouts, Modifiers & Theming
- State & Recomposition in Shared UI
- Host Shared UI on iOS & Desktop