https://kotlinlang.org logo
#compose-web
Title
# compose-web
l

louiscad

02/24/2024, 3:00 PM
Hello, I'm a bit confused as to the current Compose on the WEB situation. 1. I know the former "Compose for Web" is now "Compose HTML and manipulates the DOM inside Kotlin/JS. 2. I think that the current "Compose for Web" is Compose UI for Kotlin/WASM-JS and draws inside an HTML5Canvas, correct? 3. Sometimes, I get some indicators (example here) that it might also be possible to run Compose UI using the Kotlin/JS target inside of an HTML5Canvas. Is that correct? If so, why doesn't it seem to appear in the documentation? Also, if true, are there some info on how to setup such a project, or a trustworthy example project? I'm interested in it because I want to make a website that shows some art made in Compose Canvas, and I'd love to get the animations there, while supporting Safari, and Kotlin/WASM doesn't work there at the moment, as you probably know.
a

Arjan van Wieringen

02/24/2024, 3:05 PM
I thought Compose for Web for WASM is fully experimental whereas Compose for Web for JS is stabler-ish
r

Robert Jaros

02/24/2024, 3:21 PM
All examples in the compose multiplatform repo are currently targeting Kotlin/JS. See: https://github.com/JetBrains/compose-multiplatform/tree/master/examples/chat
👍 1
l

louiscad

02/24/2024, 3:22 PM
Hum, interesting. I wonder why it's not documented blob thinking upside down
d

Dima Avdeev

02/25/2024, 8:47 AM
Compose for HTML library is stable. But you can't share UI between Compose for HTML and other platforms. Compose for Web with JS and Wasm targets are experimental. It uses Canvas to render graphics. But you can share UI between all other platforms (Android, iOS, Desktop, Web)
👍 2
l

louiscad

02/25/2024, 9:52 AM
Why the Compose Multiplatform website only mentions the WASM target when it comes to Compose for Web, and not the JS target?
a

Arjan van Wieringen

02/25/2024, 11:46 AM
Even worse, Compose HTML is not mentioned anywhere on the docs, only in 1 paragraph of a GitHub repo, causing people to think Jetbrains is abandoning it
2
We’re using Compose HTML with great success for a highly interactive web app in production btw
🆒 5
👌🏼 1
👌🏾 1
g

Greg Steckman

02/25/2024, 7:40 PM
@louiscad Here's an example app that builds both JS and WASM targets, using the canvas (as well as desktop, iOS, Android): https://github.com/KoalaPlot/koalaplot-samples
👍 2
d

Dima Avdeev

02/26/2024, 9:57 AM
Compose Wasm target is very perspective technology! And for now it behaves very similar to Compose for Web with JS and Canvas drawing. All of it targets are experimental for now. The main benefit is possibility to share UI between all targets. (Android, Desktop, iOS, Web JS and WASM) Compose HTML library is stable. But you can't share UI between Compose HTML and other targets.
l

louiscad

02/26/2024, 10:02 AM
Yup, I think I'm getting that now. Why is Compose for Web (JS) not mentioned at all?
And why Compose HTML also gets no visibility on the Compose Multiplatform website?
I mean, I initially assumed it wasn't working on the WEB, except if you're cool with experimental stuff that won't work on Safari, which is a huge market because of iOS and iPadOS (and macOS, to a smaller extent).
j

Jilles van Gurp

02/26/2024, 11:15 AM
In it's current state, both seem a bit of a gamble for people that need something that is still going to be around and supported in a few years. Compose for HTML looks more and more like abandonware to me. Under documented and well hidden is the best you can say about it. Unless you are determined to use it, you probably shouldn't. Wasm is going to take at least another few months to stabilize. There are still major parts of the kotlinx ecosystem that don't have wasm builds and of course Kotlin 2.0 is not out yet and it doesn't really make sense to use a highly unstable/experimental thing like wasm without it. After all that stabilizes, it will take more time for the rest of the library ecosystem to start publishing wasm libraries. Maybe towards the summer we might get there. And of course there are also some major question marks around integrating with browser APIs and the rest of the js ecosystem. I've been developing against the fritz2 framework with kotlin-js for the last 3 years. It's great. We use a bunch of browser APIs, maplibre and a few other js libraries, and several multi platform libraries. I've been keeping in an eye on compose for web but so far my conclusion is that it's simply too early to move over.
i

Igor Demin

02/26/2024, 11:42 AM
See this answer for more information
👍 3
a

Arjan van Wieringen

02/26/2024, 2:24 PM
Although this helps. It’s something people easily miss. Besides, from the FAQ you can’t navigate to the “documentation” of Compose HTML. The fact that the questions about Compose Web and HTML keep popping up and people keep seeing it as abandonware (HTML part) shows that it should be more front and center. As someone who loves Kotlin, it is an extremely powerful way to make reactive web apps. And it is the ONLY production ready solution with Compose in the browser that is on offer now. It is strange that Jetbrains isn’t promoting it more, because it has huge potential.
5
z

zsmb

02/26/2024, 7:13 PM
That's good feedback, and we're aware that this is confusing at the moment. We're working towards clarifying this things in this area.
❤️ 8
l

louiscad

02/26/2024, 7:33 PM
Thank you! Looking forward to it 🙏🏼
27 Views