I don’t know if this is the right place to ask, bu...
# javascript
n
I don’t know if this is the right place to ask, but is it possible to have Electron desktop app with (partial)KotlinJS and composables? If yes, can we use SQLDelight?
c
is it possible to have Electron desktop app with (partial)KotlinJS and composables?
yes, in exactly the same manner as including Kotlin/JS in any normal JS website
can we use SQLDelight?
I don't use SQLDelight so I'm not 100% sure, but if you can use it in
js(IR) { browser() }
then it should work on Electron as well.
n
Thanks for quick reply! Where I can read more about electron+kotlin, internet doesn’t give much or my queries are bad for google
Also, will this be a Kotlin multipaltform app with electron as a library, or will it be Electron app with kotlin as a language only
c
I don't know if there are existing articles. Using Kotin/JS inside Electron is exactly the same as using Kotlin/JS inside a regular JS project (you expose your Kotlin code as a JS library, and then the consumption is identical) so you should be able to use articles for that
Essentially, your Kotlin modules will be a regular JS library (that you can publish on NPM if you want), and the Electron app can import it just like any other JS library, there's no difference on that side
n
I see, so I just compile my kotlin multipaltform sourcecode as a JS library and use this library in my electron app, is that right?
c
Yes
r
KVision has ready to use template for Electron app. You can read more here: https://kvision.gitbook.io/kvision-guide/5.-targeting-non-web-platforms/building-with-electron
c
So you can use any "compile KMP to JS library" tutorial
n
Amazing, thanks all
c
KVision doesn't support Compose, right?
But it probably doesn't make a difference for the setup
r
No it doesn't. But the application build configuration should be similar.
👍 1
n
I don’t know about that as this is my first dive into js, but I know for sure that you can build compose with kotlinJS: https://github.com/Kotlin/kotlin-wasm-examples/tree/main/compose-imageviewer#compose-multiplatform-for-web
c
Yes, you can use Compose with Kotlin/JS. KVision is another UI framework for Kotlin/JS, that doesn't use Compose. However, your problem is running Kotlin/JS code in Electron, and the solution is the same whether you use Compose or not, so you should be able to take inspiration from what the KVision team did.
If you want to specifically use Compose for Kotlin/JS, I highly recommend joining #kobweb (and their discord), I'm pretty sure at least one person there has worked with Electron before
🙌 1
r
@Nuru Nabiyev Note that Compose-Web in this example is targeting Kotlin/Wasm. I don't know if you can use Wasm with Electron.
1
🙌 1
c
If you want to use Kotlin/WASM in Electron, you should ask in #webassembly, I don't know if it's possible either. My previous answers were about Kotlin/JS (Kotlin transpiled to JS), not Kotlin/WASM (Kotlin compiled to WASM modules, then imported in JS projects).
🙌 1
n
Sooo Kotlin Multipaltform with Composable -> Kotlin/WASM -> KotlinJS -> Electron. Did I miss anything? I don’t know where KVision fits here
c
Related to Compose: • Kotlin/JS lets you use the DOM. So you use the same components as regular websites, with HTML and CSS (but written in Kotlin). If you've done web before, this will be simpler. This is also much more production-ready. I recommend #kobweb. • Kotlin/WASM uses rendering APIs directly. It uses components that are much more similar to Android's Compose. The components are already designed, however there is much more setup needed because WASM is still experimental in browsers, and it's not yet in the stable Node version, so you have to use experimental versions of everything. Electron may or may not support it. So you have to choose which kinds of components you want. • KVision is a completely different UI framework that has nothing to do with Compose. It also runs on Kotlin/JS. They already provide the setup to run KVision apps on Electron.
n
Ah I see, that’s clear now. Although then I can use any other GUI framework(s) within electron, and I don’t see the point of using KVision. Unless I want to utilize their DSL which can also be used with other GUI frameworks within
t