https://kotlinlang.org logo
#javascript
Title
# javascript
g

Gilles Barbier

03/01/2024, 8:26 AM
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

Robert Jaros

03/01/2024, 8:31 AM
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

Edoardo Luppi

03/01/2024, 9:48 AM
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

Gilles Barbier

03/01/2024, 11:19 AM
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

Edoardo Luppi

03/01/2024, 11:22 AM
Well yes, if by reactive you mean it allows real time user interactions. But for example it doesn't support text selection yet.
h

hfhbd

03/01/2024, 1:28 PM
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

Gilles Barbier

03/01/2024, 2:02 PM
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

hfhbd

03/01/2024, 3:38 PM
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

Gilles Barbier

03/01/2024, 3:55 PM
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

Robert Jaros

03/01/2024, 4:03 PM
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

hfhbd

03/01/2024, 4:11 PM
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.