Skip to content
A dual (localStorage and REST) sync adapter for Backbone.js
Pull request Compare This branch is 258 commits behind nilbus:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Backbone dualStorage Adapter v1.0

A dualStorage adapter for Backbone. It's a drop-in replacement for Backbone.Sync() to handle saving to a localStorage database as a cache for the remote models.


Include Backbone.dualStorage after having included Backbone.js:

<script type="text/javascript" src="backbone.js"></script>
<script type="text/javascript" src="backbone.dualstorage.js"></script>

Create your models and collections in the usual way. Feel free to use Backbone as you usually would, this is a drop-in replacement.

Keep in mind that Backbone.dualStorage really loves your models. By default it will cache everything that passes through Backbone.sync. You can override this behaviour with the booleans remote and local on models:

SomeModel = Backbone.Collection.extend({
    local: true  // always fetched and saved locally
    remote: true // never cached, dualStorage is bypassed entirely


Thanks to Mark Woodall for the QUnit tests. Thanks to Jerome Gravel-Niquet for Backbone.dualStorage

Something went wrong with that request. Please try again.