Lighter weight declarative UI for Kotlin JS?

I know there is a React wrapper. I haven’t used it yet, but I don’t like the looks of it. Multiplatform has been tricky enough. I’m hesitant to add yet another layer and a lot of baggage from Javascript-world.

I’m wondering if anyone is working on something written in Kotlin, for Kotlin, that uses that same principle of declarative UI, for web apps.

I’ve seen a few different Kotlin first UI frameworks. What kind are you looking for?
You can use raw JS tools if your making something simple.

I personally like the object-style APIs instead of writing HTML-style code, like what’s found in KVision.

If you want easy serverside (but also client side*) development, similar to Vaadin but much lighter, you can check out Kweb.

There are more options but it really depends on what you need.

Since I spend time with SwiftUI and Jetpack Compose, I’d like something with that declarative style (which React also has). Ideally I could just use one of those for web, but I won’t hold my breath for that.

I’ve written some pretty complicated UIs just with Kotlin/JS and OOP “controllers” that manipulate the DOM. But I like the code clarity of the declarative style.

Have a look at KVision, it is pretty impressive.

You can wait for Compose for Web as I do. Meanwhile, as they say, there are several Kotlin-first solutions. React covers most cases, but I am not happy with it (the JS part, not kotlin) and I want to try something else, but do not have time.

2 Likes

I wonder if the essential parts of React could be copied and used as a library and some design patterns in more traditional MVC code. What are these essential pieces? I can think of two at the moment…

  1. The “reconciliation” algorithm - ie, taking the UI descriptions (generated by pure functions) and using them to update the browser DOM.
  2. Imposing some global order on model change events, so that you don’t update UI that is about to be invalidated by another UI update further up the tree.

I may take a shot at this bare bones approach.

1 Like

KVision does exactly that.

I looked superficially at KVision before. I’ll take another look. Are you using it? I thought not because you mentioned waiting for Compose.

I see KVision is using this snabbdom library which is part of what I had in mind above.

I am using react for now, but I am not happy with it. Don’t have time right now to experiment with a new technology, but I really like the compose prototype. And KVision is on my to-do list.

There’s also fritz2 and doodle. Both are written entirely in kotlin and do not use virtual dom at all

1 Like