Your Kotlin code in main.kt, running on Cloudflare Workers
In addition to Wrangler v2.x you will need to install Kotlin, including a JDK and support for Gradle projects. 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 Kotlin per the linked instructions above,
./gradlew :compileProductionExecutableKotlinJs
That will compile your code and package it into a JavaScript executable, after which you can run wrangler publish
to push it to Cloudflare.
wrangler publish build/js/packages/kotlin-worker-hello-world/kotlin/kotlin-worker-hello-world.js
For more information on interop between Kotlin and Javascript, see the Kotlin docs. Regarding coroutines, see this issue and workaround