Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Store JSON data using multiple storage backends
branch: master

flight-storage Build Status

A Flight component for storing JSON data in arbitrary data stores. Currently supports:

  • Cookie
  • Data attributes
  • In-memory object
  • Local storage
  • Location hash
  • Window name


bower install --save flight-storage


define(['flight-storage/manager'], function(StorageManager) {

  // Setup the store
  StorageManager.attachTo(document, {
    adapter: 'local-storage',
    saveEvent: 'storage-save',
    getEvent: 'storage-get',
    clearEvent: 'storage-clear'

  // Listen for successful actions
  $(document).on('storage-save-success storage-get-success storage-clear-success', function(e, data) {
    console.log(e, data);

  // Listen for errors
  $(document).on('storage-save-failure storage-get-failure storage-clear-failure', function(e, data) {
    console.error(e, data);

  // Save a key/value pair
  $(document).trigger('storage-save', {key:'foo', value:{bar:'baz', boo:1337}});

  // Retrieve a key/value pair
  $(document).trigger('storage-get', {key:'foo'});

  // Clear the data store

or use the storage adapter mixins directly in your components

define(['flight/lib/component', 'flight-storage/adapters/local-storage'], function(defineComponent, withLocalStorage) {

  var MyComponent = defineComponent(myComponent, withLocalStorage);

  function myComponent() {

    this.after('initialize', function() {

      this.on('myComponentEvent', function(e, data) {
        // Save into local storage
        this.set(data.key, data.value);



  return MyComponent;


Development of this component needs Bower, and ideally Karma to be globally installed:

npm install -g bower karma

Then install the Node.js and client-side dependencies by running the following commands in the repo's root directory.

npm install
bower install

To continuously run the tests in Chrome and Firefox during development, just run:

karma start
Something went wrong with that request. Please try again.