# rememberSaveable

Common/All

## Functions summary

|---|---|---|
| `T` | `@https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable <T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/rememberSaveable.composable#rememberSaveable(kotlin.Array,kotlin.Function0)(vararg inputs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?, init: () -> T)` Remember the value produced by `https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/package-summary#rememberSaveable(kotlin.Array,kotlin.Function0)`. | Cmn |
| `T` | `@https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable <T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/rememberSaveable.composable#rememberSaveable(kotlin.Array,androidx.compose.runtime.saveable.Saver,kotlin.Function0)( vararg inputs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?, saver: https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/Saver<T, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html>, init: () -> T )` Remember the value produced by `https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/package-summary#rememberSaveable(kotlin.Array,androidx.compose.runtime.saveable.Saver,kotlin.Function0)`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableState<T>` | `@https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable <T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/rememberSaveable.composable#rememberSaveable(kotlin.Array,androidx.compose.runtime.saveable.Saver,kotlin.Function0)( vararg inputs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?, stateSaver: https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/Saver<T, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html>, init: () -> https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableState<T> )` Remember the value produced by `https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/package-summary#rememberSaveable(kotlin.Array,androidx.compose.runtime.saveable.Saver,kotlin.Function0)`. | Cmn |
| `T` | `@https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable <T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> [rememberSaveable](https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/rememberSaveable.composable#rememberSaveable(kotlin.Array,androidx.compose.runtime.saveable.Saver,kotlin.String,kotlin.Function0))( vararg inputs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?, saver: https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/Saver<T, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html>, key: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?, init: () -> T )` **This function is deprecated.** 'rememberSaveable' with a custom 'key' is no longer supported. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableState<T>` | `@https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable <T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> [rememberSaveable](https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/rememberSaveable.composable#rememberSaveable(kotlin.Array,androidx.compose.runtime.saveable.Saver,kotlin.String,kotlin.Function0))( vararg inputs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?, stateSaver: https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/Saver<T, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html>, key: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?, init: () -> https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableState<T> )` **This function is deprecated.** 'rememberSaveable' with a custom 'key' is no longer supported. | Cmn |

## Functions

### rememberSaveable

Cmn Artifact: [androidx.compose.runtime:runtime-saveable](https://developer.android.com/jetpack/androidx/releases/compose-runtime) [View Source](https://cs.android.com/search?q=file:androidx/compose/runtime/saveable/RememberSaveable.kt+function:rememberSaveable)

```
@Composable
fun <T : Any> rememberSaveable(vararg inputs: Any?, init: () -> T): T
```

Remember the value produced by `https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/package-summary#rememberSaveable(kotlin.Array,kotlin.Function0)`.

It behaves similarly to `https://developer.android.com/reference/kotlin/androidx/compose/runtime/remember.composable#remember(kotlin.Function0)`, but the stored value will survive the activity or process recreation using the saved instance state mechanism (for example it happens when the screen is rotated in the Android application).

```kotlin
import androidx.compose.runtime.saveable.rememberSaveable

val list = rememberSaveable { mutableListOf<Int>() }
```

If you use it with types which can be stored inside the Bundle then it will be saved and restored automatically using `https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/package-summary#autoSaver()`, otherwise you will need to provide a custom `https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/Saver` implementation via the `saver` param.

```kotlin
import androidx.compose.runtime.saveable.Saver
import androidx.compose.runtime.saveable.rememberSaveable

val holder = rememberSaveable(saver = HolderSaver) { Holder(0) }
```

You can use it with a value stored inside `https://developer.android.com/reference/kotlin/androidx/compose/runtime/package-summary#mutableStateOf(kotlin.Any,androidx.compose.runtime.SnapshotMutationPolicy)`.

```kotlin
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable

var value by rememberSaveable { mutableStateOf(({ "value" })()) }
```

If the value inside the MutableState can be stored inside the Bundle it would be saved and restored automatically, otherwise you will need to provide a custom `https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/Saver` implementation via an overload with which has `stateSaver` param.

```kotlin
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.Saver
import androidx.compose.runtime.saveable.rememberSaveable

val holder = rememberSaveable(stateSaver = HolderSaver) { mutableStateOf(Holder(0)) }
```

| Parameters |
|---|---|
| `vararg inputs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?` | A set of inputs such that, when any of them have changed, will cause the state to reset and `https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/package-summary#rememberSaveable(kotlin.Array,kotlin.Function0)` to be rerun. Note that state restoration DOES NOT validate against inputs provided before value was saved. |
| `init: () -> T` | A factory function to create the initial value of this state |

### rememberSaveable

Cmn Artifact: [androidx.compose.runtime:runtime-saveable](https://developer.android.com/jetpack/androidx/releases/compose-runtime) [View Source](https://cs.android.com/search?q=file:androidx/compose/runtime/saveable/RememberSaveable.kt+function:rememberSaveable)

```
@Composable
fun <T : Any> rememberSaveable(
    vararg inputs: Any?,
    saver: Saver<T, Any>,
    init: () -> T
): T
```

Remember the value produced by `https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/package-summary#rememberSaveable(kotlin.Array,androidx.compose.runtime.saveable.Saver,kotlin.Function0)`.

It behaves similarly to `https://developer.android.com/reference/kotlin/androidx/compose/runtime/remember.composable#remember(kotlin.Function0)`, but the stored value will survive the activity or process recreation using the saved instance state mechanism (for example it happens when the screen is rotated in the Android application).

```kotlin
import androidx.compose.runtime.saveable.rememberSaveable

val list = rememberSaveable { mutableListOf<Int>() }
```

If you use it with types which can be stored inside the Bundle then it will be saved and restored automatically using `https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/package-summary#autoSaver()`, otherwise you will need to provide a custom `https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/Saver` implementation via the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/package-summary#rememberSaveable(kotlin.Array,androidx.compose.runtime.saveable.Saver,kotlin.Function0)` param.

```kotlin
import androidx.compose.runtime.saveable.Saver
import androidx.compose.runtime.saveable.rememberSaveable

val holder = rememberSaveable(saver = HolderSaver) { Holder(0) }
```

You can use it with a value stored inside `https://developer.android.com/reference/kotlin/androidx/compose/runtime/package-summary#mutableStateOf(kotlin.Any,androidx.compose.runtime.SnapshotMutationPolicy)`.

```kotlin
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable

var value by rememberSaveable { mutableStateOf(({ "value" })()) }
```

If the value inside the MutableState can be stored inside the Bundle it would be saved and restored automatically, otherwise you will need to provide a custom `https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/Saver` implementation via an overload with which has `stateSaver` param.

```kotlin
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.Saver
import androidx.compose.runtime.saveable.rememberSaveable

val holder = rememberSaveable(stateSaver = HolderSaver) { mutableStateOf(Holder(0)) }
```

| Parameters |
|---|---|
| `vararg inputs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?` | A set of inputs such that, when any of them have changed, will cause the state to reset and `https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/package-summary#rememberSaveable(kotlin.Array,androidx.compose.runtime.saveable.Saver,kotlin.Function0)` to be rerun. Note that state restoration DOES NOT validate against inputs provided before value was saved. |
| `saver: https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/Saver<T, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html>` | The `https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/Saver` object which defines how the state is saved and restored. |
| `init: () -> T` | A factory function to create the initial value of this state |

### rememberSaveable

Cmn Artifact: [androidx.compose.runtime:runtime-saveable](https://developer.android.com/jetpack/androidx/releases/compose-runtime) [View Source](https://cs.android.com/search?q=file:androidx/compose/runtime/saveable/RememberSaveable.kt+function:rememberSaveable)

```
@Composable
fun <T : Any?> rememberSaveable(
    vararg inputs: Any?,
    stateSaver: Saver<T, Any>,
    init: () -> MutableState<T>
): MutableState<T>
```

Remember the value produced by `https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/package-summary#rememberSaveable(kotlin.Array,androidx.compose.runtime.saveable.Saver,kotlin.Function0)`.

It behaves similarly to `https://developer.android.com/reference/kotlin/androidx/compose/runtime/remember.composable#remember(kotlin.Function0)`, but the stored value will survive the activity or process recreation using the saved instance state mechanism (for example it happens when the screen is rotated in the Android application).

Use this overload if you remember a mutable state with a type which can't be stored in the Bundle so you have to provide a custom saver object.

```kotlin
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.Saver
import androidx.compose.runtime.saveable.rememberSaveable

val holder = rememberSaveable(stateSaver = HolderSaver) { mutableStateOf(Holder(0)) }
```

| Parameters |
|---|---|
| `vararg inputs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?` | A set of inputs such that, when any of them have changed, will cause the state to reset and `https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/package-summary#rememberSaveable(kotlin.Array,androidx.compose.runtime.saveable.Saver,kotlin.Function0)` to be rerun. Note that state restoration DOES NOT validate against inputs provided before value was saved. |
| `stateSaver: https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/Saver<T, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html>` | The `https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/Saver` object which defines how the value inside the MutableState is saved and restored. |
| `init: () -> https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableState<T>` | A factory function to create the initial value of this state |

### rememberSaveable

Cmn Artifact: [androidx.compose.runtime:runtime-saveable](https://developer.android.com/jetpack/androidx/releases/compose-runtime) [View Source](https://cs.android.com/search?q=file:androidx/compose/runtime/saveable/RememberSaveable.kt+function:rememberSaveable)

```
@Composable
fun <T : Any> [rememberSaveable](https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/rememberSaveable.composable#rememberSaveable(kotlin.Array,androidx.compose.runtime.saveable.Saver,kotlin.String,kotlin.Function0))(
    vararg inputs: Any?,
    saver: Saver<T, Any> = autoSaver(),
    key: String? = null,
    init: () -> T
): T
```

> [!CAUTION]
> **This function is deprecated.**   
> 'rememberSaveable' with a custom 'key' is no longer supported. It bypasses positional scoping, leading to state bugs and inconsistent behavior (e.g., unintentional state sharing or loss, issues in nested LazyLayouts). Please remove the 'key' parameter to use positional scoping for consistent, locally-scoped state. See https://r.android.com/3610053 for details.

Remember the value produced by `https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/package-summary#rememberSaveable(kotlin.Array,androidx.compose.runtime.saveable.Saver,kotlin.String,kotlin.Function0)`.

It behaves similarly to `https://developer.android.com/reference/kotlin/androidx/compose/runtime/remember.composable#remember(kotlin.Function0)`, but the stored value will survive the activity or process recreation using the saved instance state mechanism (for example it happens when the screen is rotated in the Android application).

```kotlin
import androidx.compose.runtime.saveable.rememberSaveable

val list = rememberSaveable { mutableListOf<Int>() }
```

If you use it with types which can be stored inside the Bundle then it will be saved and restored automatically using `https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/package-summary#autoSaver()`, otherwise you will need to provide a custom `https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/Saver` implementation via the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/package-summary#rememberSaveable(kotlin.Array,androidx.compose.runtime.saveable.Saver,kotlin.String,kotlin.Function0)` param.

```kotlin
import androidx.compose.runtime.saveable.Saver
import androidx.compose.runtime.saveable.rememberSaveable

val holder = rememberSaveable(saver = HolderSaver) { Holder(0) }
```

You can use it with a value stored inside `https://developer.android.com/reference/kotlin/androidx/compose/runtime/package-summary#mutableStateOf(kotlin.Any,androidx.compose.runtime.SnapshotMutationPolicy)`.

```kotlin
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable

var value by rememberSaveable { mutableStateOf(({ "value" })()) }
```

If the value inside the MutableState can be stored inside the Bundle it would be saved and restored automatically, otherwise you will need to provide a custom `https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/Saver` implementation via an overload with which has `stateSaver` param.

```kotlin
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.Saver
import androidx.compose.runtime.saveable.rememberSaveable

val holder = rememberSaveable(stateSaver = HolderSaver) { mutableStateOf(Holder(0)) }
```

| Parameters |
|---|---|
| `vararg inputs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?` | A set of inputs such that, when any of them have changed, will cause the state to reset and `https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/package-summary#rememberSaveable(kotlin.Array,androidx.compose.runtime.saveable.Saver,kotlin.String,kotlin.Function0)` to be rerun. Note that state restoration DOES NOT validate against inputs provided before value was saved. |
| `saver: https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/Saver<T, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> = autoSaver()` | The `https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/Saver` object which defines how the state is saved and restored. |
| `key: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html? = null` | An optional key to be used as a key for the saved value. If not provided we use the automatically generated by the Compose runtime which is unique for the every exact code location in the composition tree |
| `init: () -> T` | A factory function to create the initial value of this state |

### rememberSaveable

Cmn Artifact: [androidx.compose.runtime:runtime-saveable](https://developer.android.com/jetpack/androidx/releases/compose-runtime) [View Source](https://cs.android.com/search?q=file:androidx/compose/runtime/saveable/RememberSaveable.kt+function:rememberSaveable)

```
@Composable
fun <T : Any?> [rememberSaveable](https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/rememberSaveable.composable#rememberSaveable(kotlin.Array,androidx.compose.runtime.saveable.Saver,kotlin.String,kotlin.Function0))(
    vararg inputs: Any?,
    stateSaver: Saver<T, Any>,
    key: String? = null,
    init: () -> MutableState<T>
): MutableState<T>
```

> [!CAUTION]
> **This function is deprecated.**   
> 'rememberSaveable' with a custom 'key' is no longer supported. It bypasses positional scoping, leading to state bugs and inconsistent behavior (e.g., unintentional state sharing or loss, issues in nested LazyLayouts). Please remove the 'key' parameter to use positional scoping for consistent, locally-scoped state. See https://r.android.com/3610053 for details.

Remember the value produced by `https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/package-summary#rememberSaveable(kotlin.Array,androidx.compose.runtime.saveable.Saver,kotlin.String,kotlin.Function0)`.

It behaves similarly to `https://developer.android.com/reference/kotlin/androidx/compose/runtime/remember.composable#remember(kotlin.Function0)`, but the stored value will survive the activity or process recreation using the saved instance state mechanism (for example it happens when the screen is rotated in the Android application).

Use this overload if you remember a mutable state with a type which can't be stored in the Bundle so you have to provide a custom saver object.

```kotlin
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.Saver
import androidx.compose.runtime.saveable.rememberSaveable

val holder = rememberSaveable(stateSaver = HolderSaver) { mutableStateOf(Holder(0)) }
```

| Parameters |
|---|---|
| `vararg inputs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?` | A set of inputs such that, when any of them have changed, will cause the state to reset and `https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/package-summary#rememberSaveable(kotlin.Array,androidx.compose.runtime.saveable.Saver,kotlin.String,kotlin.Function0)` to be rerun. Note that state restoration DOES NOT validate against inputs provided before value was saved. |
| `stateSaver: https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/Saver<T, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html>` | The `https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/Saver` object which defines how the value inside the MutableState is saved and restored. |
| `key: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html? = null` | An optional key to be used as a key for the saved value. If not provided we use the automatically generated by the Compose runtime which is unique for the every exact code location in the composition tree |
| `init: () -> https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableState<T>` | A factory function to create the initial value of this state |