Can a Compose Multiplatform common module be used to create UI models used by both JVM and JS Kotlin modules

Hello, I am currently working on a new project and was looking into using Compose Multiplatform for it.

Essentially, I need to create a Desktop + Web application that looks exactly the same in terms of the UI and flow.

How feasible is it to use Compose Multiplatform for something like this? So far I have set up separate Kotlin/JVM and Kotlin/JS modules which both depend on a shared multi-target common module. I have tested this and it works, however the introduction of the ‘org.jetbrains.compose’ library in the shared module creates problems which I believe have to do with the way Kotlin compiles dependencies for differing targets.

In turn, this makes it difficult to create common UI objects that can be re-used through the use of the shared module and limits this shared module to domain modelling only - as far as I can see anyway. It would be nice to be able to create these common UI objects and be able to use them across both the Desktop and Web modules.

Is it possible that there is a way to achieve Composable backed UI modelling in the shared module which has both a JVM and JS target? Or is this currently something that is not supported?

Happy to hear about any other solutions and answer questions too.

Thank you in advance!

1 Like