Hey guys, is it possible to use Compose for Web an...
# compose
e
Hey guys, is it possible to use Compose for Web and have Ktor based backend on the same Netty web server instance? If I follow
<https://play.kotlinlang.org/hands-on/Full%20Stack%20Web%20App%20with%20Kotlin%20Multiplatform>
I get this error:
The Compose Compiler requires the Compose Runtime to be on the class path, but none could be found
while compiling jvm target. I have compose dependencies specified only for js target, but it looks like the Compose Plugin is used for jvm and it causes the error. How could I fix that? Are there any sample projects with Compose and Ktor backend working together?
r
This approach works for me. What version of the compose plugin are you using?
I put the compose deps into `commonMain`:
Copy code
val commonMain by getting {
  dependencies {
    api(compose.runtime)
    api(compose.web.core)
  }
}
e
@rocketraman so you are adding compose dependencies for all targets, even where it is not needed, right?
r
Right
Thinking back on it, pretty sure it was to resolve the issue you raised.
e
@rocketraman thank you! btw, did you try to use several modules? I came across this solution here: https://github.com/JetBrains/compose-jb/issues/1568
r
I remember seeing that issue, but no I did not pursue the separate modules approach. Didn't seem worth it.
💪 1
If you try it, let me know if it works for you though.
👍 1
e
@rocketraman tried out multi module setup. It was a bit tricky, but finally it looks like it is working as expected.
👍 1
r
Nice, thanks for the update. Is this a project you can share? I'd love to see your gradle setup.