linux-china / kotlin-wasm-browser-demo

Kotlin WebAssembly demo for Browser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Kotlin WebAssembly hello world in a browser

Install Chrome Canary(unstable)

Install latest Chrome Canary(120+) from https://www.google.com/intl/en_us/chrome/canary/

After install, open chrome://flags and enable all WebAssembly flags to active WebAssembly Garbage Collection.

Kotlin 1.9.20-Beta2 is out!

  • ⚠️ Since this version, Kotlin/Wasm uses final opcodes for Wasm GC and TFR* proposals.
  • ⚠️ So, it may require updating your wasm environment!

For Chrome, Chromium-based browsers, and Firefox, you need version 119.

Get started

./gradlew wasmJsBrowserRun -t

Testing on Google Canary

Visit http://localhost:8000/index.html

You will see Hello World! on page. Kotlin WebAssembly code as following:

fun main() {
    val p = document.createElement("p")
    p.innerHTML = "Hello World!"
    document.body.appendChild(p)
}

References

About

Kotlin WebAssembly demo for Browser


Languages

Language:Just 41.4%Language:HTML 34.9%Language:Kotlin 23.7%