A caching layer between the client and server.

Backbone localStorage Sync

An extension to Backbone providing localStorage caching for sync operations


  • Test usage examples
  • Implement Read Collections
  • Implement Create
  • Implement Update
  • Implement Delete


Backbone.localStorageSync(originalSyncLayer, uniqueName, options)

The provided values are the defaults.

    alwaysUpdate: true //Fetch the model from original Sync even if it was available in the localStorage
require(['backbone', 'backbone.localstoragesync'], function(Backbone, localStorageSync) {
    var model = new Backbone.Model({
        sync: new localStorageSync(Backbone.sync, 'testModel')

    model.fetch().done(function () {
        //Use as normal

Add the script after Backbone. Then you get a global as Backbone.localStorageSync and can use it like this:

var model = new Backbone.Model({
    sync: new Backbone.localStorageSync(Backbone.sync, 'testModel')

model.fetch().done(function () {
    //Use as normal

When you use an AMD loader you need to have those libraries available under the stated name. If you use RequireJS and have trouble check the shim config.

localStorage and JSON have to be globaly available otherwise the provided Sync layer will be returned.

###Optional require.js


Backbone.localStorageSync is Copyright (C) 2012 Liip AG. It is distributed under the MIT license.

It is inspired by: Backbone.cachingSync Backbone.localStorage