Kotlin multiplatform: a new cross-platform contender to ReactNative and Flutter
After ReactNative and Flutter, a new cross-platform solution is emerging: Kotlin Multiplatform Mobile (KMM) has just been released in alpha.
Kotlin Multiplatform allows you to share logic written in Kotlin between Android and iOS, and to access native APIs for each platform.
At the moment, it is not possible to share UI code, and we don't really know if this is an actual goal of this project.
But why not a cross-platform UI solution based on Jetpack Compose (alpha released last week), the Kotlin declarative UI framework built by Google?
It is currently possible to share code such as:
- business logic
The Kotlin code becomes available for consuming in SwiftUI/Objective-C based iOS applications.
Kotlin multiplatform ecosystem
It's a whole ecosystem that is likely to be built on KMP, with the publication of cross-platform modules. For example, Reaktive is a Kotlin multiplatform module of Reactive Extensions (Observables).
An open-sourced demo app (PeopleInSpace) supports all these platforms:
- Android (Jetpack Compose)
- iOS, watchOS, macOS (SwiftUI)
- Web (ReactJS)
- backend (JVM/Ktor)
It looks like, if sharing UI code is not needed, Kotlin is able to share everything else, and would be a good cross-platform choice.
React-Native is a strong platform for cross-platform development. It has many escape hatches which makes it not so risky to adopt. I almost see it as a dependency injection framework to inject platform-specific primitives where default React-Native abstractions are not a good fit. The React-Native re-architecture (Fabric/JSI/Turbomodules) should be available in the upcoming year, and help remove many of the performance issues we could encounter so far. It is also a serious cross-platform solution, with Microsoft building React-Native-MacOs and React-Native-Windows, and Web support already used on highly critical products such as Twitter (see React-Native-Web and my blog post about Atomic CSS-in-JS).
Flutter is also a strong platform. Its tradeoffs are different compared React-Native, but both platforms looks good, and should be chosen according to the usecase and context. The mobile support is good and can very often outperform ReactNative, but web support is improving but it's still not perfect, as SEO and small JS bundles matter for the web.
SwiftUI: I'm not sure Apple wants to help on cross-platform development, but there is this project Scade that enables to create Android apps with Swift, and Vapor allows to run Swift on the backend. It does not look like the most mature option.
WebView: Adobe is stopping to invest in PhoneGap, yet Max Lynch, creator of Ionic and Capacitor (modern alternative to Cordova), continue to bet on the web platform, and think ReactJS (and not ReactNative) might be the better choice for cross-platform
This is exciting times for cross-platform development, and happy to see a new viable alternatives to more established ones.
If you like cross-platform related news, follow me on Twitter.
It looks like, if sharing UI code is not needed, Kotlin is able to share everything else
I think that's the key take away, KMP does not address multiplatform UI re-use, so not really addressing the main problem that Flutter and ReactNative do.