
Cross-platform WebView component exposing WebViewState and navigator APIs; backed by native OS webviews via Rust+UniFFI (Wry), with JS-native bridge, cookie API, request interceptor.
ComposeNativeWebView is a Compose Multiplatform WebView whose API design and mobile implementations (Android & iOS) are intentionally derived almost verbatim from KevinnZou/compose-webview-multiplatform.
Package namespace:
dev.nucleusframework.webview.*
⚠️ Breaking change (v1.0.0+) — migrating from pre-Nucleus / Wry builds
Classpath / package — rename imports and package references:
io.github.kdroidfilter.webview.*→dev.nucleusframework.webview.*- Maven coordinates:
io.github.kdroidfilter:…→dev.nucleusframework:composewebviewDesktop is Tao-only — the old Wry desktop backend is removed. Desktop WebView requires the Nucleus Tao backend (
NativeView):
- App entry:
nucleusApplication(backend = NucleusBackend.Tao) { … }- Dependencies: Nucleus application +
decorated-window-tao(Swing/Compose Desktop without Tao will not host the WebView)Why Tao? Native WebViews are opaque platform surfaces. Tao’s
NativeViewembeds them in the same window stack as Compose, so you can draw Compose UI on top of the WebView (toolbars, dialogs, loading overlays, chrome) instead of fighting a separate HWND/GTK child. You also get the rest of Tao’s desktop stack (decorated window, title bar, input routing, multiplatform windowing) in one path.Android, iOS and WasmJs keep the same API shape; only the package and Maven group change.
Reused on purpose
WebViewState, WebViewNavigator, settings, callbacks, mental model)android.webkit.WebView)WKWebView)If you already know compose-webview-multiplatform, you already know how to use this.
What ComposeNativeWebView adds
dev.nucleusframework)android.webkit.WebView
WKWebView
org.w3c.dom.HTMLIFrameElement
NativeView (requires nucleusApplication / Tao backend).
libcompose_webview_linux.so)compose_webview_windows.dll; needs WebView2 Runtime / Edge)libcompose_webview_macos.dylib)@Composable
fun App() {
val state = rememberWebViewState("https://example.com")
WebView(state, Modifier.fillMaxSize()) {
// Optional Compose overlay on top of the native WebView
// (NativeView content slot on desktop; Box overlay elsewhere).
}
}That’s it.
dependencies {
implementation("dev.nucleusframework:composewebview:<version>")
}Same artifact for Android, iOS, Desktop and WasmJs.
VisualSuiteApp + suiteCatalog() live in e2e-shared commonMain.
Every platform host runs that same suite against a real WebView:
| Host | Command | Backend |
|---|---|---|
| Desktop | ./gradlew :e2e-desktop:run |
Tao + WebKit2GTK / WKWebView / WebView2 |
| Android |
./gradlew :e2e-android:installDebug then launch app |
android.webkit.WebView |
| Wasm | ./gradlew :e2e-wasmJs:wasmJsBrowserDevelopmentRun |
IFrame |
| iOS | open iosApp in Xcode and Run |
WKWebView |
Cases that need a platform-only capability (history on Wasm, isolated native profiles on desktop, pixel screenshots, …) are Skipped with a reason — not Failed — so the catalog stays identical.
Same pure-logic packages on JVM / Android host / iOS simulator / Wasm browser:
COMMON='--tests dev.nucleusframework.webview.jsbridge.* --tests dev.nucleusframework.webview.web.* --tests dev.nucleusframework.webview.request.* --tests dev.nucleusframework.webview.cookie.* --tests dev.nucleusframework.webview.setting.*'
./gradlew :webview-compose:jvmTest $COMMON
./gradlew :webview-compose:testDebugUnitTest $COMMON
./gradlew :webview-compose:iosSimulatorArm64Test $COMMON # macOS
./gradlew :webview-compose:wasmJsBrowserTest $COMMONloadUrl(url, headers)loadHtml(html)loadHtmlFile(fileName, readType)navigateBack(), navigateForward()
reload(), stopLoading()
canGoBack, canGoForward
isLoadingloadingStatelastLoadedUrlpageTitleUnified cookie API:
state.cookieManager.setCookie(...)
state.cookieManager.getCookies(url)
state.cookieManager.removeCookies(url)
state.cookieManager.removeAllCookies()navigator.evaluateJavaScript("document.title = 'Hello'")window.kmpJsBridge.callNative("echo", {...}, callback)Intercept navigator-initiated navigations only:
override fun onInterceptUrlRequest(
request: WebRequest,
navigator: WebViewNavigator
): WebRequestInterceptResultUseful for:
val state = rememberWebViewState(
url = "https://example.com"
) {
customUserAgentString = "MyApp/1.0"
}Supports:
val navigator = rememberWebViewNavigator()
WebView(state, navigator)Commands:
loadUrlloadHtmlloadHtmlFileevaluateJavaScriptstate.webSettings.customUserAgentString = "MyApp/1.2.3"state.webSettings.logSeverity = KLogSeverity.Debugwebview-compose/ → Compose Multiplatform API + platform actuals + commonTeste2e-shared/ → shared multiplatform visual e2e suite (VisualSuiteApp)e2e-desktop/, e2e-android/, e2e-wasmJs/, iosApp/ → platform hosts for that suitenucleusApplication + decorated-window-tao). Linux (WebKit2GTK), macOS (WKWebView) and Windows (WebView2) are fully wired.ComposeNativeWebView is a Compose Multiplatform WebView whose API design and mobile implementations (Android & iOS) are intentionally derived almost verbatim from KevinnZou/compose-webview-multiplatform.
Package namespace:
dev.nucleusframework.webview.*
⚠️ Breaking change (v1.0.0+) — migrating from pre-Nucleus / Wry builds
Classpath / package — rename imports and package references:
io.github.kdroidfilter.webview.*→dev.nucleusframework.webview.*- Maven coordinates:
io.github.kdroidfilter:…→dev.nucleusframework:composewebviewDesktop is Tao-only — the old Wry desktop backend is removed. Desktop WebView requires the Nucleus Tao backend (
NativeView):
- App entry:
nucleusApplication(backend = NucleusBackend.Tao) { … }- Dependencies: Nucleus application +
decorated-window-tao(Swing/Compose Desktop without Tao will not host the WebView)Why Tao? Native WebViews are opaque platform surfaces. Tao’s
NativeViewembeds them in the same window stack as Compose, so you can draw Compose UI on top of the WebView (toolbars, dialogs, loading overlays, chrome) instead of fighting a separate HWND/GTK child. You also get the rest of Tao’s desktop stack (decorated window, title bar, input routing, multiplatform windowing) in one path.Android, iOS and WasmJs keep the same API shape; only the package and Maven group change.
Reused on purpose
WebViewState, WebViewNavigator, settings, callbacks, mental model)android.webkit.WebView)WKWebView)If you already know compose-webview-multiplatform, you already know how to use this.
What ComposeNativeWebView adds
dev.nucleusframework)android.webkit.WebView
WKWebView
org.w3c.dom.HTMLIFrameElement
NativeView (requires nucleusApplication / Tao backend).
libcompose_webview_linux.so)compose_webview_windows.dll; needs WebView2 Runtime / Edge)libcompose_webview_macos.dylib)@Composable
fun App() {
val state = rememberWebViewState("https://example.com")
WebView(state, Modifier.fillMaxSize()) {
// Optional Compose overlay on top of the native WebView
// (NativeView content slot on desktop; Box overlay elsewhere).
}
}That’s it.
dependencies {
implementation("dev.nucleusframework:composewebview:<version>")
}Same artifact for Android, iOS, Desktop and WasmJs.
VisualSuiteApp + suiteCatalog() live in e2e-shared commonMain.
Every platform host runs that same suite against a real WebView:
| Host | Command | Backend |
|---|---|---|
| Desktop | ./gradlew :e2e-desktop:run |
Tao + WebKit2GTK / WKWebView / WebView2 |
| Android |
./gradlew :e2e-android:installDebug then launch app |
android.webkit.WebView |
| Wasm | ./gradlew :e2e-wasmJs:wasmJsBrowserDevelopmentRun |
IFrame |
| iOS | open iosApp in Xcode and Run |
WKWebView |
Cases that need a platform-only capability (history on Wasm, isolated native profiles on desktop, pixel screenshots, …) are Skipped with a reason — not Failed — so the catalog stays identical.
Same pure-logic packages on JVM / Android host / iOS simulator / Wasm browser:
COMMON='--tests dev.nucleusframework.webview.jsbridge.* --tests dev.nucleusframework.webview.web.* --tests dev.nucleusframework.webview.request.* --tests dev.nucleusframework.webview.cookie.* --tests dev.nucleusframework.webview.setting.*'
./gradlew :webview-compose:jvmTest $COMMON
./gradlew :webview-compose:testDebugUnitTest $COMMON
./gradlew :webview-compose:iosSimulatorArm64Test $COMMON # macOS
./gradlew :webview-compose:wasmJsBrowserTest $COMMONloadUrl(url, headers)loadHtml(html)loadHtmlFile(fileName, readType)navigateBack(), navigateForward()
reload(), stopLoading()
canGoBack, canGoForward
isLoadingloadingStatelastLoadedUrlpageTitleUnified cookie API:
state.cookieManager.setCookie(...)
state.cookieManager.getCookies(url)
state.cookieManager.removeCookies(url)
state.cookieManager.removeAllCookies()navigator.evaluateJavaScript("document.title = 'Hello'")window.kmpJsBridge.callNative("echo", {...}, callback)Intercept navigator-initiated navigations only:
override fun onInterceptUrlRequest(
request: WebRequest,
navigator: WebViewNavigator
): WebRequestInterceptResultUseful for:
val state = rememberWebViewState(
url = "https://example.com"
) {
customUserAgentString = "MyApp/1.0"
}Supports:
val navigator = rememberWebViewNavigator()
WebView(state, navigator)Commands:
loadUrlloadHtmlloadHtmlFileevaluateJavaScriptstate.webSettings.customUserAgentString = "MyApp/1.2.3"state.webSettings.logSeverity = KLogSeverity.Debugwebview-compose/ → Compose Multiplatform API + platform actuals + commonTeste2e-shared/ → shared multiplatform visual e2e suite (VisualSuiteApp)e2e-desktop/, e2e-android/, e2e-wasmJs/, iosApp/ → platform hosts for that suitenucleusApplication + decorated-window-tao). Linux (WebKit2GTK), macOS (WKWebView) and Windows (WebView2) are fully wired.