Kickstart Kotlin Web Assembly with Spring Boot

Submitted by Dickens A S on Sun, 11/03/2019 - 13:22

Easily create Kotlin Web Assembly project from these multiplatform boilerplate Gradle DSL

GitHub https://github.com/dickensas/kotlin-gradle-templates/tree/master/sboot-wasm

Kotlin Code

package wasm

fun main() {
    println("Hello World!")
}

JavaScript Code

No need to write JavaScript code simply put this HTML

<script src="build/bin/wasm/releaseExecutable/sboot_wasm.wasm.js" wasm="build/bin/wasm/releaseExecutable/sboot_wasm.wasm"> </script>

Run gradle command

  gradle assemble

Run gradle command

  gradle run

Browse http://localhost:8080/index.html

Check your browser console for text output "Hello World!" which will be the output from Web Assembly Code

Spring Boot is used as a server to give MIME content-type as "application/wasm" , currently browsers does not recognize .wasm files with that MIME

More Codes

WebGL WebAssembly

WebAssembly Writing To Buffer

WebAssembly String Byte By Byte

WebAssembly DOM Access by Stub

 

 

Add new comment