---
title: "Saver"
description: "The [Saver] describes how the object of [Original] class can be simplified and converted into
something which is [Saveable].

What types can be saved is defined by [SaveableStateRegistry], by default everything which can be
stored in the Bundle class can be saved. The implementations can check that the provided value
can be saved via [SaverScope.canBeSaved]

You can pass the implementations of this class as a parameter for [rememberSaveable]."
type: "function"
---

<div class='type'>Function</div>


<a id='references'></a>
<div class='sourceset sourceset-common'>Common</div>


```kotlin
public fun <Original, Saveable : Any> Saver(
    save: SaverScope.(value: Original) -> Saveable?,
    restore: (value: Saveable) -> Original?,
): Saver<Original, Saveable>
```


The `Saver` describes how the object of `Original` class can be simplified and converted into
something which is `Saveable`.

What types can be saved is defined by `SaveableStateRegistry`, by default everything which can be
stored in the Bundle class can be saved. The implementations can check that the provided value
can be saved via `SaverScope.canBeSaved`

You can pass the implementations of this class as a parameter for `rememberSaveable`.

#### Parameters

| | |
| --- | --- |
| save | Defines how to convert the value into a saveable one. If null is returned the value will not be saved. |
| restore | Defines how to convert the restored value back to the original Class. If null is returned the value will not be restored and would be initialized again instead. |




## Code Examples
### CustomSaverSample
```kotlin
@Composable
fun CustomSaverSample() {
    data class Holder(var value: Int)
    // this Saver implementation converts Holder object which we don't know how to save
    // to Int which we can save
    val HolderSaver = Saver<Holder, Int>(save = { it.value }, restore = { Holder(it) })
}
```

