Kotlin hello world for Cloudflare Workers

Your Kotlin code in main.kt, running on Cloudflare Workers

In addition to Wrangler 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.


To generate using wrangler

wrangler generate projectname https://github.com/cloudflare/kotlin-worker-hello-world

Further documentation for Wrangler can be found here.


After setting up Kotlin per the linked instructions above,

cd projectname
./gradlew buildWorker

That will compile your code and package it into index.js, after which you can run wrangler publish to push it to Cloudflare.

For more information on interop between Kotlin and Javascript, see the Kotlin docs. Regarding coroutines, see this issue and workaround


View Github