# feed


06/02/2021, 9:42 AM
Announcing Krosstalk, a fully multiplatform pure Kotlin RPC library. Serialization, client, and server implementations are pluggable (Ktor and kotlinx.serialization are provided), and using `expect`/`actual` to enforce method signatures and share configuration is fully supported (and is in fact the main intended use case). Once you configure common, client, and server using an
expect object
), declaring a RPC method is as simple as:
Copy code
// common
expect suspend fun basicTest(n: Int): List<String>

// client (i.e. js)
actual suspend fun basicTest(n: Int): List<String> = krosstalkCall()

// server (i.e. jvm)
actual suspend fun basicTest(n: Int): List<String> = List(n) { "$it" }
See the README for the full example, and details.
🌟 3

Piotr Krzemiński

06/02/2021, 9:55 AM
looks nice! I was trying to achieve something similar with but then learned that KVision has something like this (CC: @Robert Jaros). I'm wondering if we should try to make it 1 instead of 3, the goals seem very close 🙂

Big Chungus

06/02/2021, 9:58 AM
What does that annotation do?


06/02/2021, 10:08 AM
seems to be used by a compiler plugin to generate or modify code .. i think that should be in the readme and demo..
Copy code
plugins {


06/02/2021, 10:10 AM
can it generate restful routes? (post for create, put for update, etc)
👍 1

Big Chungus

06/02/2021, 2:51 PM
I'm not too interested in rpc, but compiler plugins are definitely on my radar. So good find! Thanks for sharing. It'd be great if you could document your journey writing it in 🙏


06/02/2021, 9:07 PM
@christophsturm Yes, if you use endpoints. It generates them internally anyways, but they will be named things like
POST krosstalk/myMethod_12f45
, so if you actually want to call them externally use
@Nikky Note the
Gradle plugin (required)
in the readme. I should probably make it a bit more obvious.
@Big Chungus the compiler plugin is actually fairly simple, as far as compiler plugins go, it just registers the method by adding an init block to the object in
, and on the client side, replaces
with something like"n" to n))
(for the example)

Big Chungus

06/02/2021, 9:23 PM
That's exactly what I need for my project, but there are very little resources to get started with compiler plugins, unfortunately.


06/02/2021, 9:27 PM
I'd recommend [this blog](, and [this one for some tips]( Most of the work is going to be familiarizing yourself with the IR classes, finding edge cases, and reporting bugs on youtrack. There was a whole lot of "try it and see", but my use at least was pretty straightforward.
👍 1
@Piotr Krzemiński It looks like you were using codegen by a gradle task, and kvision is using a annotation processor (It's used via compiler plugin but generates text, I have no idea how that works). KVisions is a lot more opinionated, which I think is probably intentional, so I don't know how much we would mesh. Other than that though, I'm happy to have issues or PRs. Especially for plugins.
Ktor is also working on something similar with their Locations, I think.