Session Storage State Source

Provides a simple way of storing state in session storage.

var FooStorage = Marty.createStateSource({
  namespace: 'foos',
  type: 'sessionStorage',
  saveFoo: function (foo) {
    this.set('bar', foo);
  getFoo: function (id) {
    return this.get(id);
class FooStorage extends Marty.SessionStorageStateSource {
  constructor(options) {
    this.namespace = 'foos';
  saveFoo(foo) {
    this.set('bar', foo);
  getFoo(id) {
    return this.get(id);


An (optional) prefix for keys.


Gets the item in the storage with the given key. If the item exists, it will deserialize it.

set(key, obj)

Serializes the object to a JSON string before and then inserts into the storage with the given key.