Kotlin has the power to build applications, and reuse mobile and desktop user interfaces (UIs) in your web projects with Compose Multiplatform and Kotlin/Wasm.
Compose Multiplatform is a declarative framework based on Kotlin and Jetpack Compose, which allows you to implement the UI once and share it across all the platforms you target. Specifically for web platforms, Compose Multiplatform uses Kotlin/Wasm as its compilation target.
WebAssembly (Wasm) is a binary instruction format for a stack-based virtual machine. This format is platform-independent because it runs on its own virtual machine. Wasm provides Kotlin and other languages with a compilation target to run on the web.
Kotlin/Wasm compiles your Kotlin code into Wasm format. Using Kotlin/Wasm, you can create applications that run on different environments and devices, which support Wasm and meet Kotlin's requirements.
Would you like to try it yourself?
Although Kotlin/Wasm is still in Alpha, Compose Multiplatform running on Kotlin/Wasm already shows encouraging performance traits. You can see that the execution speed outperforms JS and is getting close to JVM:
We regularly run benchmarks on Kotlin/Wasm, and these results come from our testing in a recent version of Google Chrome.
Browser API support
The Kotlin/Wasm standard library provides declarations for browser APIs (including the DOM API). With these declarations, you can directly use the Kotlin API to access and utilize various browser functionalities. For example, in your Kotlin/Wasm applications, you can use manipulation with DOM elements or fetch API, without defining these declarations from scratch. To learn more, see our Kotlin/Wasm browser example.