<div class='sourceset sourceset-android'>Android</div>

```kotlin
public interface SpatialExternalSurfaceScope
```

[SpatialExternalSurfaceScope](/jetpack-compose/androidx.xr.compose/compose/interfaces/SpatialExternalSurfaceScope) is a scoped environment that provides the [Surface](/jetpack-compose/androidx.compose.material/material/components/Surface) associated with
a [SpatialExternalSurface](/jetpack-compose/androidx.xr.compose/compose/composable-functions/SpatialExternalSurface)

## Functions

<h2 id="onsurfacecreated-onsurfacecreated">onSurfaceCreated</h2>

```kotlin
public fun onSurfaceCreated(onSurfaceCreated: (Surface) -> Unit)
```

Invoked only one time when the Surface is created. This will execute before any layout or
modifiers are computed.

<hr class="docs-overload-divider">

<h2 id="onsurfacedestroyed-onsurfacedestroyed">onSurfaceDestroyed</h2>

```kotlin
public fun onSurfaceDestroyed(onSurfaceDestroyed: (Surface) -> Unit)
```

Invoked when the Composable and its associated [Surface](/jetpack-compose/androidx.compose.material/material/components/Surface) are destroyed.