Compiling same Kotlin code to JVM and JS

I’ve found this Compiling Kotlin to both Java and Javascript from the same module

but it is old and I can’t find any new info regarding compiling the same module to JVM and JS.

My main interest would be to create a validation library that I can use on backend and frontend.

Thanks in advance.

Kind Regards,


check out this Kotlin project:

I think gives you an example of the current only available solution (note that you are limited to depend only to kotlin-stdlib-common which is a stripped version of the stdlib for each target, jvm or js - meaning it does not contain compile target specific code)

Study the modules, shared, jvm and js. jvm and js depends on shared where
the shared code lies. You have to have separate modules for each kotlin
compile target (and to fill in the holes of target specific


Thank you very much Jørund,

I will dive into it.

And if you use gradle, you can also take a look at how kotlin-test library is built, which is also a multiplatform project: kotlin/libraries/kotlin.test at master · JetBrains/kotlin · GitHub

Please note that the multiplatform project support is in the pre-release state, so no compatibility guaranties are given whatsoever.