Your Kotlin code in main.kt, running on Cloudflare Workers
In addition to Wrangler v2.x you will need to install a JDK 8 or newer. The easiest way to do this is using the free Community Edition of IntelliJ IDEA.
Configure the wrangler.toml by filling in the account_id
from the Workers pages of your Cloudflare Dashboard.
Further documentation for Wrangler can be found here.
After setting up your environment, run the following command:
./gradlew :compileProductionExecutableKotlinWasmJs
That will compile your code into a WebAssembly executable and JavaScript glue code,
after which you can run wrangler deploy
to push it to Cloudflare:
npx wrangler@latest deploy build/js/packages/kotlin-worker-hello-world-wasm-js/kotlin/kotlin-worker-hello-world.js