# Persisting values

**URL:** <https://talk.observablehq.com/t/persisting-values/206>\
**Category:** Uncategorized\
**Created:** [February 2, 2018, 6:14am UTC](https://talk.observablehq.com/t/persisting-values/206 "2018-02-02T06:14:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![shaunlebron](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/shaunlebron/32/81_2.png) [@shaunlebron](https://talk.observablehq.com/u/shaunlebron)\
**Post date:** [February 2, 2018, 6:14am UTC](https://talk.observablehq.com/t/persisting-values/206/1 "2018-02-02T06:14:38Z")

</div>

Can values be persisted across sessions? My use-case is to persist some slider values as I explore them.

Since `localStorage` does not work in a sandboxed iframe—nor should it—I was wondering if adding a `Storage` API to the standard library would be appropriate.

It could potentially `postMessage` to the parent frame to save/load `localStorage` values namespaced to the current notebook. So persisting a slider value might look like this:

```auto
viewof x = {
  const range = html`<input type=range min=0 max=100>`;
  range.value = 50; // default value

  const key = 'myval';
  range.addEventListener("input", () => Storage.save(key, range.value));
  Storage.load(key).then(value => {
    range.value = value; // load persisted value
    range.dispatchEvent(new Event('input'));
  });

  return range;
}

```

---

<div class="post-metadata">

**Author:** ![tom](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/tom/32/2262_2.png) [@tom](https://talk.observablehq.com/u/tom)\
**Post date:** [February 5, 2018, 8:20pm UTC](https://talk.observablehq.com/t/persisting-values/206/2 "2018-02-05T20:20:53Z")

</div>

Yep, definitely! Mike especially interested in APIs that both provide _value persistence_ and potentially _value sharing_. Because the Observable runtime knows about all values that cross ‘cell boundaries’, we could be able to do something like providing collaborative environments for some notebooks, as well as the ability to start where you left off last.
