Kotlin Help

Kotlin/Wasm

Kotlin/Wasm has the power to compile your Kotlin code into WebAssembly (Wasm) format. With Kotlin/Wasm, you can create applications that run on different environments and devices, which support Wasm and meet Kotlin's requirements.

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.

Kotlin/Wasm supports two targets for different environments:

In addition to supporting different environments, the two targets differ in their levels of QA coverage and tooling support. The wasmJs target currently receives broader support than wasmWasi:

  • QA coverage: wasmJs has broad QA coverage, including Kotlin Gradle plugin integration tests and IntelliJ IDEA tests. wasmWasi has narrower QA and Kotlin Gradle plugin test coverage, with no dedicated IntelliJ IDEA tests.

  • Build tool support: for wasmWasi, you need to opt in to use WASI-specific features in the Kotlin Gradle plugin.

  • IDE support: only wasmJs supports debugging in the IDE and running code from the editor gutter.

UI frameworks for Kotlin/Wasm

With Kotlin/Wasm, you have the power to build applications and reuse mobile and desktop user interfaces (UIs) in your web projects through different UI frameworks, such as Compose Multiplatform.

Choose a framework based on your UI requirements, preferred rendering approach, and whether you need to share the UI with other platforms.

Compose Multiplatform

Compose Multiplatform is a declarative framework based on Kotlin and Jetpack Compose that allows you to implement the UI once and share it across all the platforms you target.

For web platforms, Compose Multiplatform uses Kotlin/Wasm as its compilation target. Applications built with Kotlin/Wasm and Compose Multiplatform use a wasmJs target and run in browsers.

Additionally, you can use the most popular Kotlin libraries in Kotlin/Wasm out of the box. Like in other Kotlin and Multiplatform projects, you can include dependency declarations in the build script. For more information, see Adding dependencies on multiplatform libraries.

Would you like to try it yourself?

Get started with Kotlin/Wasm

Doodle

Doodle is a UI framework for sharing applications between web and desktop. It supports Kotlin/Wasm and Kotlin/JS for the web, and JVM for desktop.

Doodle uses vector-based rendering, giving you control over custom UI components, shapes, gradients, and visualizations.

Kilua

Kilua is a web framework based on the Compose Multiplatform runtime. It uses standard HTML elements to render UIs.

Kilua provides declarative components, reactive state management, routing, and integration with CSS frameworks such as Bootstrap and Tailwind CSS. It also supports server-side rendering.

Summon

Summon is a Kotlin Multiplatform frontend framework that supports Kotlin/Wasm, Kotlin/JS, and JVM. It provides a declarative API for reusable UI components, reactive state management, and type-safe styling.

Summon supports server-side rendering and integration with JVM backend frameworks, including Ktor and Spring Boot.

Kotlin/Wasm and WASI

Kotlin/Wasm uses the WebAssembly System Interface (WASI) for backend applications. Applications built with Kotlin/Wasm and WASI use a Wasm-WASI target, allowing you to call the WASI API and run applications outside the browser environment.

Kotlin/Wasm leverages WASI to abstract away platform-specific details, allowing the same Kotlin code to run across diverse platforms. This expands the reach of Kotlin/Wasm beyond web applications without requiring custom handling for each runtime.

WASI provides a secure, standardized interface for running Kotlin applications compiled to WebAssembly across different environments.

WebAssembly Component Model

WASI 0.2 is built on the WebAssembly Component Model, which defines a way to build components from Wasm modules using standardized interfaces and types. The model lets you define language-agnostic components in applications or libraries. You can also compose Wasm modules and existing components into new components.

To explore what's possible with the WebAssembly Component Model and Kotlin/Wasm, check out this demo of a simple server built with wasi:http.

Kotlin/Wasm with WebAssembly Component Model

Kotlin/Wasm performance

Kotlin/Wasm can improve execution performance compared with Kotlin/JS. The results depend on the workload, the framework, and the browser or runtime.

For example, the Compose Multiplatform benchmarks show Kotlin/Wasm outperforming Kotlin/JS and approaching JVM performance in the measured workloads:

Kotlin/Wasm performance

We regularly run benchmarks on Kotlin/Wasm, and these results come from our testing in a recent version of Google Chrome.

For results from more frameworks, see Summon's performance comparison.

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 the API without defining these declarations from scratch. To learn more, see our Kotlin/Wasm browser example.

The declarations for browser API support are defined using JavaScript interoperability capabilities. You can use the same capabilities to define your own declarations. In addition, Kotlin/Wasm–JavaScript interoperability allows you to use Kotlin code from JavaScript. For more information, see Use Kotlin code in JavaScript.

Leave feedback

Kotlin/Wasm feedback

Compose Multiplatform feedback

Learn more

26 November 2026