A Different Approach to Cross-Platform
Unlike Flutter and React Native, which render their own UI on top of native platforms, Kotlin Multiplatform (KMP) shares business logic — networking, data models, view models — while letting each platform keep its fully native UI (SwiftUI on iOS, Jetpack Compose on Android).
Sharing a Data Layer
// commonMain - shared across iOS and Android
class ProductRepository(private val api: ApiClient) {
suspend fun getProducts(): List<Product> {
return api.get("/products").body()
}
}
@Serializable
data class Product(val id: String, val name: String, val price: Double)
Platform-Specific UI, Shared ViewModel
// commonMain
class ProductListViewModel(private val repository: ProductRepository) {
private val _state = MutableStateFlow<List<Product>>(emptyList())
val state: StateFlow<List<Product>> = _state
suspend fun load() {
_state.value = repository.getProducts()
}
}
// androidMain - Jetpack Compose UI
@Composable
fun ProductListScreen(viewModel: ProductListViewModel) {
val products by viewModel.state.collectAsState()
LazyColumn {
items(products) { product => Text(product.name) }
}
}
// iosMain - SwiftUI consuming the same shared ViewModel
struct ProductListView: View {
@StateObject var viewModel: ProductListViewModelWrapper
var body: some View {
List(viewModel.products, id: \.id) { product in
Text(product.name)
}
}
}
The Core Trade-off vs Flutter/React Native
| Approach | UI | Shared Code |
|---|---|---|
| Flutter | Custom-rendered, identical across platforms | Everything, including UI |
| React Native | Bridges to native components | Most logic and UI structure |
| KMP | Fully native per platform | Business logic only, not UI |
When KMP Makes Sense
- You need pixel-perfect native UI conventions on each platform (not “close to native” — actually native)
- You already have native iOS/Android teams and want to reduce duplicated business logic, not UI code
- Deep platform-specific integrations are a priority and you don’t want an abstraction layer in the way
When KMP Is the Wrong Choice
- You want a single team building one UI codebase for both platforms — that’s Flutter or React Native’s actual value proposition
- You don’t have (or want to build) separate iOS and Android UI expertise
- Fast prototyping matters more than long-term native UI fidelity
Current Maturity
KMP for mobile (KMM) is production-ready and used by major companies, but the ecosystem of shared libraries is smaller than Flutter’s or React Native’s, and you’re still writing and maintaining two UI codebases — just with shared business logic underneath.
Conclusion
KMP isn’t a drop-in replacement for Flutter or React Native — it’s a different trade-off entirely, sharing logic while keeping UI fully native and platform-specific. Choose it when native UI fidelity matters more than single-codebase UI development speed.