Dropbox Datastore API adapter for Backbone.js

bower install backbone.dbxDatastore


Backbone Dropbox Datastore API Adapter

It's a drop-in replacement for Backbone.Sync() to handle saving to a Dropbox Datastore. Inspired by Backbone.localStorage


Include Backbone.dbxDatastore after having included Backbone.js:

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

Obtain datastore object (example from Dropbox Datastore API Tutorial) and save it to Backbone.dbxDatastore.datastore. From that moment you are ready to create model or collection instances and sync them.

var client = new Dropbox.Client({key: APP_KEY});

client.authenticate({interactive: false}, function (error) {
    if (error) {
        alert('Authentication error: ' + error);

if (client.isAuthenticated()) {
  var datastoreManager = client.getDatastoreManager();
  datastoreManager.openDefaultDatastore(function (error, datastore) {
      if (error) {
          alert('Error opening default datastore: ' + error);

      // Now you have a datastore. Time to resolve deferred object

Create your collections like so:

window.SomeCollection = Backbone.Collection.extend({
  dbxDatastore: new Backbone.DbxDatastore("some_collection"), // Table name for Dropbox Datastore.
  // ... everything else is normal.

Bower and RequireJS

Add dependency to bower.json

"backbone.dbxDatastore": "~0.2.0"

Include RequireJS:

<!-- build:js scripts/main.js -->
  <script data-main="scripts/main" src="bower_components/requirejs/require.js"></script>
<!-- endbuild -->

RequireJS config:

    paths: {
        jquery: '../bower_components/jquery/jquery',
        underscore: '../bower_components/underscore/underscore',
        backbone: '../bower_components/backbone/backbone',
        dropbox: 'vendor/dropbox-datastores',
        dbxDatastore: '../bower_components/backbone.dbxDatastore/dist/backbone.dbxDatastore'

Define your collection as a module:

define("someCollection", ["dbxDatastore"], function() {
    var SomeCollection = Backbone.Collection.extend({
        dbxDatastore: new Backbone.DbxDatastore("some_collection") // Table name for Dropbox Datastore.
    return new SomeCollection();

Require your collection:

require(["someCollection"], function(someCollection) {
  // ready to use someCollection


If you're using browserify.

var Backbone.DbxDatastore = require("backbone.dbxdatastore");