JetBrains previews Jetpack Compose for Web

Posted on 05-05-2021 , by: admin , in , 0 Comments

JetBrains is offering its first technology preview of Jetpack Compose for the Web, which brings Google’s Kotlin toolkit for building reactive user interfaces to the web.

Introduced on May 3, Jetpack Compose for Web works on top of Kotlin Multiplatform, enabling developers to build an application for Android, the desktop, or web using Jetpack Compose as the UI framework, all within the same project. Kotlin Multiplatform fosters sharing of platform-agnostic functionality such as business logic through common code, while still enabling developers to implement platform-specific functionality.

Jetpack Compose for Web follows JetBrains’ Compose for Desktop, for building reactive desktop UIs for Kotlin, also still in early development, with a 1.0 release planned. With the Jetpack Compose for Web preview, developers can reuse all core Compose state management concepts across platforms. The preview currently does not allow developers to directly reuse existing widgets, but the Kotlin Multiplatform expect/actual mechanism can be used to build common widgets with implementations for all three platforms.

The Jetpack Compose for Web preview includes two types of APIs for designing user interfaces in Kotlin: a composable DOM API, to control the document object model, and a web implementation of widgets from Jetpack Compose for Desktop and Jetpack Compose for Android. JetBrains also is designing a type-safe DSL for style sheets, through which CSS rules can be expressed in Kotlin. Developers can modify styles based on the state of a Compose application, Jetbrains said.

Instructions on getting started with Jetpack Compose for Web can be found on GitHub.