Hello, I'm quite familiar in using Kotlin as an ap...
# javascript
g
Hello, I'm quite familiar in using Kotlin as an application language, but has no experience in using it for web development. I like the frameworks like Livewire for PHP that let us build SPA using only server-side updates. In Kotlin, I'm aware of https://docs.kweb.io/book/ that does similar things, but I'm wondering if there is a more standard way? As Kotlin can be transpiled in javascript, I'm wondering if there is standard way to build SPA?
r
There are different Kotlin/JS frameworks for building typical SPA. You can check #compose-web (probably the most "standard" as it's developed by JB) but also #kvision, #react, #kobweb, #doodle, #fritz2.
👀 1
e
Compose Web is still difficult to adopt tho. Not because of its alpha state, but because using WASM for web apps is still niche. You can probably use it for fun projects at this point. To me it seems the "Kotlin for the web" ecosystem is still in its infancy, but I see a lot of cool stuff coming out of the mentioned frameworks.
g
Thanks for the comments, after reading it seems that #fritz2 is what I'm looking for, but the community is much smaller than Compose. Does compose supports reactive UI? It's not clear to me quickly reading the documentation
e
Well yes, if by reactive you mean it allows real time user interactions. But for example it doesn't support text selection yet.
h
Just for completeness, there is also compose HTML. We are using this in a Gradle mono repo: 1) shared api + dataclasses, 2) ktor backend server and 3) Kotlin JS Frontend using compose html. The JS and html files are served by the ktor server.
g
Frankly, the landscape is a bit complex. I come both from java applications and "classical" web development - and I struggle a bit to understand the options and the differences
h
Well, it depends on your use-case. What do you want to use: server side rendering or client based rendering? Do you want to use a reactive UI framework? How do your users consume your website, mobile or desktop? What about offline usage or low data connectivity?
g
Thx. I’d like a reactive UI. I do not care really about client-base or server side rendering, as long as I can use Kotlin only. I need also to be able to do server-side operations, such as fetching data from Kafka. I target browsers (web and mobile) only with a good data connection.
r
I think all the frameworks mentioned above support reactive UI.
There are pros and cons of all of them, but as I'm the author of one of them, I don't feel entitled to judge publicly 😉
🙂 1
h
Yeah, and Kotlin JS (or wasm) is only the language. You can also use plain React/Angular with Kotlin JS. So you have the choice, but all mentioned UI frameworks above uses client side rendering, which is pretty much the standard today. Beside the UI framework, I would also recommend a shared Kotlin module containing the data classes to reuse them between your server and your web client if you want to use client side rendering.