|
1 | 1 |
|
2 | 2 | [](https://github.com/JetBrains#jetbrains-on-github)
|
3 | 3 |
|
4 |
| -# Compose Multiplatform for Web |
| 4 | +This example showcases a web application built with [Compose Multiplatform for web](#compose-multiplatform-for-web) and [Kotlin/Wasm](https://kotl.in/wasm). |
5 | 5 |
|
6 |
| -> **Note** |
7 |
| -> Web support is Experimental and may be changed at any time. Use it only for evaluation purposes. |
8 |
| -> We would appreciate your feedback on it in the public Slack channel [#compose-web](https://slack-chats.kotlinlang.org/c/compose-web). |
9 |
| -> If you face any issues, please report them on [GitHub](https://github.com/JetBrains/compose-multiplatform/issues). |
| 6 | +Check it out: |
10 | 7 |
|
11 |
| -You can experiment with sharing your mobile or desktop UIs with the web. Compose for Web is based on [Kotlin/Wasm](https://kotl.in/wasm), |
12 |
| -the newest target for Kotlin Multiplatform projects. It allows Kotlin developers to run their code in the browser with |
13 |
| -all the benefits that WebAssembly has to offer, such as good and predictable performance for your applications. |
14 |
| - |
15 |
| -# Compose for Web Example |
16 |
| - |
17 |
| -A simple Compose Multiplatform App. |
| 8 | +[](https://kotlin.github.io/kotlin-wasm-compose-template/). |
18 | 9 |
|
19 | 10 | 
|
20 | 11 |
|
21 |
| -## Build and run |
| 12 | +## Compose Multiplatform for web |
| 13 | + |
| 14 | +> **Note:** |
| 15 | +> Web support is an [Alpha](https://kotlinlang.org/docs/components-stability.html) feature. It may be changed at any time. |
| 16 | +> You can use it in scenarios before production. We would appreciate your feedback on [GitHub](https://github.com/JetBrains/compose-multiplatform/issues). |
| 17 | +> |
| 18 | +> [Join the compose-web community](https://slack-chats.kotlinlang.org/c/compose-web). |
| 19 | +
|
| 20 | +Compose Multiplatform for web enables sharing your mobile or desktop UIs on the web. |
| 21 | + |
| 22 | +Compose Multiplatform for web is based on [Kotlin/Wasm](https://kotl.in/wasm), the newest target for Kotlin Multiplatform projects. |
| 23 | +This enables running your code in the browser, leveraging WebAssembly's advantages like high and consistent application performance. |
| 24 | + |
| 25 | +Follow the instructions in the sections below to try out this application built with Compose Multiplatform for web and Kotlin/Wasm. |
| 26 | + |
| 27 | +## Set up the environment |
| 28 | + |
| 29 | +Before starting, ensure you have the necessary IDE and browser setup to run the application. |
| 30 | + |
| 31 | +### IDE |
| 32 | + |
| 33 | +We recommend using [IntelliJ IDEA 2023.1 or later](https://www.jetbrains.com/idea/) to work with the project. |
| 34 | +It supports Kotlin/Wasm out of the box. |
| 35 | + |
| 36 | +### Browser (for Kotlin/Wasm target) |
22 | 37 |
|
23 |
| -Check out the repo, navigate to the project folder, and use the following commands: |
| 38 | +To run applications built with Kotlin/Wasm in a browser, you need a browser supporting the [Wasm Garbage Collection (GC) feature](https://github.com/WebAssembly/gc): |
24 | 39 |
|
25 |
| -### Run Web version via Gradle |
| 40 | +**Chrome and Chromium-based** |
| 41 | + |
| 42 | +* **For version 119 or later:** |
| 43 | + |
| 44 | + Works by default. |
| 45 | + |
| 46 | +**Firefox** |
| 47 | + |
| 48 | +* **For version 120 or later:** |
| 49 | + |
| 50 | + Works by default. |
| 51 | + |
| 52 | +**Safari/WebKit** |
| 53 | + |
| 54 | +Wasm GC support is currently under |
| 55 | +[active development](https://bugs.webkit.org/show_bug.cgi?id=247394). |
| 56 | + |
| 57 | +> **Note:** |
| 58 | +> For more information about the browser versions, see the [Troubleshooting documentation](https://kotl.in/wasm_help/). |
| 59 | +
|
| 60 | +## Build and run |
26 | 61 |
|
27 |
| -`./gradlew :composeApp:wasmJsRun` |
| 62 | +To build and run the application: |
28 | 63 |
|
29 |
| -### Run Desktop version via Gradle |
| 64 | +1. In IntelliJ IDEA, open the repository. |
| 65 | +2. Run the application by typing one of the following Gradle commands in the terminal: |
30 | 66 |
|
31 |
| -`./gradlew :composeApp:run` |
| 67 | +* **Web version:** |
32 | 68 |
|
33 |
| -## Setup Environment |
| 69 | + `./gradlew :composeApp:wasmJsRun` |
| 70 | + <br> <br> |
34 | 71 |
|
35 |
| -To run applications built with Kotlin/Wasm in a browser, you need a browser supporting [wasm garbage collection feature](https://github.com/WebAssembly/gc): |
| 72 | + Once the application starts, open the following URL in your browser: |
36 | 73 |
|
37 |
| -- For **Chrome** and **Chromium-based** browsers (Edge, Brave etc.), it **should just work** since version 119. |
38 |
| -- For **Firefox** 120 it **should just work**. |
39 |
| -- For **Firefox** 119: |
40 |
| - 1. Open `about:config` in the browser. |
41 |
| - 2. Enable **javascript.options.wasm_gc**. |
42 |
| - 3. Refresh the page. |
| 74 | + `http://localhost:8080` |
43 | 75 |
|
44 |
| -For more information see https://kotl.in/wasm_help/. |
| 76 | + > **Note:** |
| 77 | + > The port number can vary. If the port 8080 is unavailable, you can find the corresponding port number printed in the console |
| 78 | + > after building the application. |
| 79 | +<br> <br> |
45 | 80 |
|
46 |
| -## IDE |
| 81 | +* **Desktop version:** |
47 | 82 |
|
48 |
| -We recommend using [IntelliJ IDEA 2023.1 or newer](https://www.jetbrains.com/idea/) to work with the project. |
| 83 | + `./gradlew :composeApp:run` |
49 | 84 |
|
50 |
| -# Feedback & Questions |
| 85 | +## Feedback and questions |
51 | 86 |
|
52 |
| -Give it a try, and share your feedback and ask questions in the Kotlin Slack [#compose-web](https://slack-chats.kotlinlang.org/c/compose-web) channel (if you’re not a member, [apply here](https://kotl.in/slack)) or on Twitter to [@bashorov](https://twitter.com/bashorov). |
| 87 | +Give it a try and share your feedback or questions in our [#compose-web](https://slack-chats.kotlinlang.org/c/compose-web) Slack channel. |
| 88 | +[Get a Slack invite](https://surveys.jetbrains.com/s3/kotlin-slack-sign-up). |
| 89 | +You can also share your comments with [@bashorov](https://twitter.com/bashorov) on X (Twitter). |
53 | 90 |
|
54 |
| -# Learn more |
| 91 | +## Learn more |
55 | 92 |
|
56 | 93 | * [Compose Multiplatform](https://github.com/JetBrains/compose-multiplatform/#compose-multiplatform)
|
57 | 94 | * [Kotlin/Wasm](https://kotl.in/wasm/)
|
58 |
| -* [Other examples](../../../#examples) |
| 95 | +* [Other Kotlin/Wasm examples](https://github.com/Kotlin/kotlin-wasm-examples/tree/main) |
0 commit comments