Hello, I'm a bit confused as to the current Compos...
# compose-web
l
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
I thought Compose for Web for WASM is fully experimental whereas Compose for Web for JS is stabler-ish
r
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
Hum, interesting. I wonder why it's not documented blob thinking upside down
d
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
Why the Compose Multiplatform website only mentions the WASM target when it comes to Compose for Web, and not the JS target?
a
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
@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
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
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
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
See this answer for more information
đź‘Ť 3
a
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.
âž• 6
z
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.
❤️ 9
l
Thank you! Looking forward to it 🙏🏼