# rememberNestedScrollInteropConnection

Common/AllAndroid/JVM

## Functions summary

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/nestedscroll/NestedScrollConnection` | `@https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/rememberNestedScrollInteropConnection.composable#rememberNestedScrollInteropConnection(android.view.View)(hostView: https://developer.android.com/reference/android/view/View.html)` Create and `https://developer.android.com/reference/kotlin/androidx/compose/runtime/remember.composable#remember(kotlin.Function0)` the `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/nestedscroll/NestedScrollConnection` that enables Nested Scroll Interop between a View parent that implements `https://developer.android.com/reference/kotlin/androidx/core/view/NestedScrollingParent3` and a Compose child. | android |

## Functions

### rememberNestedScrollInteropConnection

android Artifact: [androidx.compose.ui:ui](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/platform/NestedScrollInteropConnection.android.kt+function:rememberNestedScrollInteropConnection) Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.4.0)

```
@Composable
fun rememberNestedScrollInteropConnection(hostView: View = LocalView.current): NestedScrollConnection
```

Create and `https://developer.android.com/reference/kotlin/androidx/compose/runtime/remember.composable#remember(kotlin.Function0)` the `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/nestedscroll/NestedScrollConnection` that enables Nested Scroll Interop between a View parent that implements `https://developer.android.com/reference/kotlin/androidx/core/view/NestedScrollingParent3` and a Compose child. This should be used in conjunction with a `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/nestedscroll/nestedScroll.modifier#(androidx.compose.ui.Modifier).nestedScroll(androidx.compose.ui.input.nestedscroll.NestedScrollConnection,androidx.compose.ui.input.nestedscroll.NestedScrollDispatcher)` modifier. Nested Scroll is enabled by default on the compose side and you can use this connection to enable both nested scroll on the view side and to add glue logic between View and compose.

Note that this only covers the use case where a cooperating parent is used. A cooperating parent is one that implements NestedScrollingParent3, a key layout that does that is `https://developer.android.com/reference/kotlin/androidx/coordinatorlayout/widget/CoordinatorLayout`.

```kotlin
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.platform.rememberNestedScrollInteropConnection
import androidx.compose.ui.unit.dp

val nestedSrollInterop = rememberNestedScrollInteropConnection()
// Add the nested scroll connection to your top level @Composable element
// using the nestedScroll modifier.
LazyColumn(modifier = Modifier.nestedScroll(nestedSrollInterop)) {
    items(20) { item ->
        Box(
            modifier =
                Modifier.padding(16.dp).height(56.dp).fillMaxWidth().background(Color.Gray),
            contentAlignment = Alignment.Center,
        ) {
            Text(item.toString())
        }
    }
}
```

| Parameters |
|---|---|
| `hostView: https://developer.android.com/reference/android/view/View.html = LocalView.current` | The View that hosts the compose scrollable, this is usually a ComposeView. Learn how to enable nested scroll interop: |