Webview in Compose Android

2 min readJul 31, 2023

In this blog we will learn how to create webview with Jetpack Compose. You can view webpages and can send intent to external browsers to load web url.

In-App Webview

In Compose there isn’t dedicated component for webview. Webview is part of the android view itself.

Webview can be defined like as the example shown below.

private fun WebviewScreen(url: String) = AndroidView(
modifier = Modifier
factory = {
WebView(it).apply {
webViewClient = WebViewClient()

This view takes in the URL provided as function parameter and loads the webview with the given URL.


Webview via Intent

If you want view to be redirected to browser with Intent then following can be done.

private fun WebViewScreen(url: String, context: Context) =
context.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url)))


That’s all for now. Thanks.

Please feel free to reach out to me on LinkedIn.

If you liked this blog, don’t forget to hit the 👏 .