> Documentation index: https://developer.android.com/reference/llms.txt

# WebSurface

## Functions summary

|---|---|
| `Unit` | `@Composable @RequiresFeature(name = "WEB_SURFACE", enforcement = "androidx.web.WebFeature#isFeatureSupported") WebSurface(content: WebContent, modifier: Modifier)` Presents the web page hosted by `WebContent`. |
| `Unit` | `@Composable @RequiresFeature(name = "WEB_SURFACE", enforcement = "androidx.web.WebFeature#isFeatureSupported") <T : WebViewBridge> WebSurface( content: WebContent, bridgeFactory: (Context) -> T, modifier: Modifier, bridgeRelease: (T) -> Unit, bridgeUpdate: (T) -> Unit )` Presents the web page hosted by `WebContent`, using a `WebViewBridge` to access `android.webkit.WebView` APIs that are not yet available directly on `WebContent`. |

## Functions

### WebSurface

Artifact: [androidx.web:web-compose](https://developer.android.com/jetpack/androidx/releases/web.md.txt) [View Source](https://cs.android.com/search?q=file:androidx/web/compose/WebSurface.kt+function:WebSurface) Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/web.md.txt#1.0.0-alpha02)

```
@Composable
@RequiresFeature(name = "WEB_SURFACE", enforcement = "androidx.web.WebFeature#isFeatureSupported")
fun WebSurface(content: WebContent, modifier: Modifier = Modifier): Unit
```

Presents the web page hosted by `WebContent`.

`WebSurface` has no intrinsic size and defaults to the minimum constraints of its parent, so a size should be specified via `modifier` (for example using `Modifier.fillMaxSize()`, `Modifier.size()`, or `Modifier.weight()`).

Only a single `WebSurface` can present `content` at a time. A `WebSurface` entering composition takes over `content` in the same frame from the `WebSurface` presenting it.

| Parameters |
|---|---|
| `content: WebContent` | The `WebContent` hosting the web session to present. |
| `modifier: Modifier = Modifier` | The `Modifier` to be applied to this layout node. |

| See also |
|---|---|
| `WebContent` |   |
| `WEB_SURFACE` |   |

### WebSurface

Artifact: [androidx.web:web-compose](https://developer.android.com/jetpack/androidx/releases/web.md.txt) [View Source](https://cs.android.com/search?q=file:androidx/web/compose/WebSurface.kt+function:WebSurface)

```
@Composable
@RequiresFeature(name = "WEB_SURFACE", enforcement = "androidx.web.WebFeature#isFeatureSupported")
fun <T : WebViewBridge> WebSurface(
    content: WebContent,
    bridgeFactory: (Context) -> T,
    modifier: Modifier = Modifier,
    bridgeRelease: (T) -> Unit = NoOpUpdate,
    bridgeUpdate: (T) -> Unit = NoOpUpdate
): Unit
```

Presents the web page hosted by `WebContent`, using a `WebViewBridge` to access `android.webkit.WebView` APIs that are not yet available directly on `WebContent`.

`WebSurface` has no intrinsic size and defaults to the minimum constraints of its parent, so a size should be specified via `modifier` (for example using `Modifier.fillMaxSize()`, `Modifier.size()`, or `Modifier.weight()`).

When this composable enters composition, `bridgeFactory` is invoked on the UI thread to create and attach a `WebViewBridge` to `content`. The provided `Context` *must* be used to construct the `WebViewBridge`. In addition to creating the `WebViewBridge`, the `bridgeFactory` block can also be used to perform one-off initializations and set constant properties. The `bridgeUpdate` block can run multiple times (on the UI thread as well) due to recomposition, and it is the right place to set new properties or trigger state-driven updates on the `WebViewBridge`. Note that `bridgeUpdate` will also run once right after the `bridgeFactory` block completes. When this composable leaves composition, `bridgeRelease` is invoked and the `WebViewBridge` is automatically detached from `content`.

Only a single `WebSurface` can present `content` at a time. A `WebSurface` entering composition takes over `content` in the same frame from the `WebSurface` presenting it.

| Parameters |
|---|---|
| `content: WebContent` | The `WebContent` hosting the web session to present. |
| `bridgeFactory: (Context) -> T` | The block creating the `WebViewBridge` to be attached to `content`. This block is called once when the composable enters composition, or if the `content` instance changes. The provided `Context` must be passed to the `WebViewBridge` constructor. |
| `modifier: Modifier = Modifier` | The `Modifier` to be applied to this layout node. |
| `bridgeRelease: (T) -> Unit = NoOpUpdate` | A callback invoked when the composable leaves composition, or if the `content` instance changes. Clean up any references to the `WebViewBridge` here, but don't call `android.webkit.WebView.destroy`. |
| `bridgeUpdate: (T) -> Unit = NoOpUpdate` | A callback to be invoked after the `WebViewBridge` is created and upon recomposition to update the information and state of the `WebViewBridge`. |

| See also |
|---|---|
| `WebContent` |   |
| `WebViewBridge` |   |
| `WEB_SURFACE` |   |