I found this framework because I am looking for a ...
# kobweb
p
I found this framework because I am looking for a way to migrate my TypeScript React components to Kotlin. I do not want to use the Kotlin-React wrappers, as I dislike the React-specific overhead (compared to function calls with named arguments in Compose). Everything except the React components has already been migrated to Kotlin (Redux reducer, actions, state, side effects, API client) because it is reused in Compose Multiplatform for Android, iOS, and desktop. This all works very well, but the remaining TypeScript files are starting to annoy me — mainly because refactoring the Kotlin parts requires manual updates to the TypeScript files. So far, I am considering kobweb/compose-html) as an alternative for the React parts — though I still need to check what third-party libraries I would need to replace and how (for example, react-virtualized). On a more general level, I would prefer if the framework allowed for a less opinionated setup. For example, I would like to control the app’s entry point and set up the router myself. Currently, my entry point is already a
@Composable
. Ideally, I would like something similar to an
Application
class that I fully control. Comparing this to React, where you explicitly call the initial render function:
Copy code
ReactDOM.createRoot(document.getElementById("root")).render(...);
I am also looking into the Kilua project and I prefer its approach: https://github.com/rjaros/kilua/blob/main/examples/todomvc/src/commonMain/kotlin/TodoApp.kt In Kilua, you own the entry point, and you can set up dependencies like
ApiClient
and
Storage
classes outside of any
@Composable
. Routes are described as part of your app’s component tree, and nested routes are supported (e.g., for a navigation bar, main/details view). One important use case for this is passing the router into a DI container and using it inside side effects (such as Redux-Observables) to programmatically change the user’s route (for example, redirecting to the login screen on any “forbidden” response). Right now, this kind of navigation is only possible inside a page’s content.
c
Kobweb is split into multiple things; Kobweb is the entire framework, but you can use some parts of it without using others. In particular, Silk is a set of Compose HTML components to make it more convenient to write sites. For example, it includes
Modifier
. To me, it seems that maybe you'd want to use Compose HTML directly (so you own the entrypoint etc), and use Silk on top, rather than use the entirety of Kobweb?
p
Thanks for the explanation. I think I will try it out to create my own entry point setup. Can you link me the required libs?
c
d
Thanks Ivan! Here's a README for using Silk widgets without using Kobweb: https://github.com/varabyte/kobweb/tree/main/frontend/silk-widgets/README.md Or if you like some of the foundational classes from Silk but don't want widgets: https://github.com/varabyte/kobweb/blob/main/frontend/silk-foundation One can also use https://github.com/varabyte/kobweb/tree/main/frontend/compose-html-ext and/or https://github.com/varabyte/kobweb/tree/main/frontend/browser-ext and/or https://github.com/varabyte/kobweb/tree/main/frontend/kobweb-compose (where Modifier lives) without Kobweb. However, if Kilua works for you, you should use it! Join the #C06UAH52PA7 channel if you haven't already.