Hi everyone, i am thinking to build a KMP project ...
# multiplatform
v
Hi everyone, i am thinking to build a KMP project targeting web and android Planning to go with Shared Business Logic + Native UI (Jetpack Compose/React JS) I have a few questions, can anyone help me out ? • For web, should i target kotlin/js or kotlin/wasm? • I want to keep KMP, Android and Web as separate projects with separate repositories, how will this work? Will kmp project become a artifact on maven, which is then consumed by android and a NPM dependency which is consumed by the Frontend ?
a
Hi @Vaibhav Jaiswal • For sharing business logic we recommend to use Kotlin/JS. More here. • Exactly. You will need to publish both artifacts to Maven and NPM and use them as the regular dependencies in the projects. We're working on documentation for NPM publishing, but right now you can take a look to this Gradle Plugin.
v
I see, thanks How will i link the kmp library to the reactJs WebApp if i plan to keep web in the same project, inside the webApp directory?
a
You can do this with NPM workspace feature. A hello world example of such project you can create with the KMP wizard: https://kmp.jetbrains.com/?android=true&ios=true&iosui=compose&web=true&webui=react&includeTests=true Or view here (as a github template): https://github.com/Kotlin/kmp-logic-sharing-simple-example#readme
v
Hi, i created a new project from the KMP Wizard, but when i try to run
npm i
it throws this error
Copy code
~/Projects/AISe/AIse_kmp git:[develop]
npm i
npm error code ETARGET
npm error notarget No matching version found for shared@0.0.0-unspecified.
npm error notarget In most cases you or one of your dependencies are requesting
npm error notarget a package version that doesn't exist.
npm error A complete log of this run can be found in: /Users/vaibhav/.npm/_logs/2025-08-29T07_56_34_062Z-debug-0.log
a
Interesting, do you run
npm i
from the root or from the
webApp
?
v
From root
a
Interesting, let me try it and I will come back
Oh, yep, sure. As the first step we need to build the shared as an npm library (we don't have it as a workspace yet). So, please, try firstly:
Copy code
./gradlew :shared:jsBrowserDevelopmentLibraryDistribution
And after that it should be available for npm to set the dependency
v
thanks, it works now