1# WebView wrapper for Jetpack Compose 2 3[](https://search.maven.org/search?q=g:com.google.accompanist) 4 5A library which provides a Jetpack Compose wrapper around Android's WebView. 6 7!!! warning 8 **This library is deprecated, and the API is no longer maintained. We recommend forking the implementation and customising it to your needs.** The original documentation is below. 9 10## Usage 11 12To implement this wrapper there are two key APIs which are needed: [`WebView`](../api/web/com.google.accompanist.web/-web-view.html), which is provides the layout, and [`rememberWebViewState(url)`](../api/web/com.google.accompanist.web/remember-web-view-state.html) which provides some remembered state including the URL to display. 13 14The basic usage is as follows: 15 16```kotlin 17val state = rememberWebViewState("https://example.com") 18 19WebView( 20 state 21) 22``` 23 24This will display a WebView in your Compose layout that shows the URL provided. 25 26There is a larger sample in the sample app which can be found [here](https://github.com/google/accompanist/blob/main/sample/src/main/java/com/google/accompanist/sample/webview/BasicWebViewSample.kt). This sample also shows how to show a loading state. 27 28### WebView settings including JavaScript 29 30By default, JavaScript is disabled in the WebView. To enable it or any other settings you can use the `onCreated` callback. 31 32```kotlin 33WebView( 34 state = webViewState, 35 onCreated = { it.settings.javaScriptEnabled = true } 36) 37``` 38 39### Capturing back presses 40 41By default the WebView will capture back presses/swipes when relevant and navigate the WebView back. This can be disabled via the parameter on 42the Composable. 43 44```kotlin 45WebView( 46 ... 47 captureBackPresses = false 48) 49``` 50 51### Using a subclass of WebView 52 53If you want to use a subclass of `WebView`, or simply require more control over its instantiation, you can provide a factory. 54 55```kotlin 56WebView( 57 ... 58 factory = { context -> CustomWebView(context) } 59) 60``` 61 62## Download 63 64[](https://search.maven.org/search?q=g:com.google.accompanist) 65 66```groovy 67repositories { 68 mavenCentral() 69} 70 71dependencies { 72 implementation "com.google.accompanist:accompanist-webview:<version>" 73} 74``` 75