Escriu per cercar…

Wasm

Compose can be compiled to WebAssembly (Wasm) for use in modern browsers.

Aquesta pàgina encara no s'ha traduït — es mostra en l'idioma original:English

Introduction

With Kotlin, you have the power to build applications and reuse mobile and desktop user interfaces (UIs) in your web projects through Compose and Wasm.

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

Explore this online demo of an application built with Compose Multiplatform and Kotlin/Wasm

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.

Get started

Get Started

Create a new project with the Web target and the Share UI.

Once the project loads, select composeApp [wasmJs] in the list of run configurations and click Run.

The web application opens automatically in your browser. Alternatively, you can open the following URL in your browser when the run is finished:

http://localhost:8080/

Note

The port number can vary because the 8080 port may be unavailable. You can find the actual port number in the output of the Gradle build.

Gradle

You can run the wasmJsBrowserDevelopmentRun task to compile the project and open the HTML file in the browser.

ps
.\gradlew wasmJsBrowserDevelopmentRun

If you prefer, you can use the --continuous flag to keep the browser open and automatically reload the page when you modify the code.

ps
.\gradlew wasmJsBrowserDevelopmentRun --continuous

Generate artifacts

Generate your project’s artifacts to publish on a website:

ps
./gradlew wasmJsBrowserDistribution

Estàs llegint una vista prèvia.

Inicia sessió per llegir l'article complet. Qualsevol compte obre 4 articles gratuïts al mes; l'alumnat i el professorat llegeixen les pàgines del seu curs sense límit.

Inicia sessió