I need a client side browser database. What are my options [closed] I need a client side browser database. What are my options [closed] database database

I need a client side browser database. What are my options [closed]


I'm about 5 years late in answering this, but given that there are errors and outdated data in some of the existing answers, and unaddressed points in the original question, I figured i'd throw in my two cents.

First, contrary to what others have implied on here, localStorage is not a database. It is (or should be perceived as) a persistent, string-based key-value store...

...which may be perfectly fine for your needs (and brings me to my second point).

  • Do you need explicit or implicitly relationships between your data items?
  • How about the ability to query over said items?
  • Or more than 5 MB in space?

If you answered "no" to all all of the above, go with localStorage and save yourself from the headaches that are the WebSQL and IndexedDB APIs. Well, maybe just the latter headache, since the former has been deprecated.

There are also several other client-side storage facilities (native and non-native) you may want to look in to, some of which are deprecated* but still see support from some browsers:

Check out BakedGoods if you want to utilize any of these facilities, and more, without having to write low-level storage operation code. With it, placing data in one (or more) of them, for example, is as simple as:

bakedGoods.set({    data: [{key: "key1", value: "val1"}, {key: "key2", value: "val2"}],    storageTypes: ["silverlight", "fileSystem", "localStorage"],    options: optionsObj,    complete: function(byStorageTypeStoredKeysObj, byStorageTypeErrorObj){}});

Oh, and for the sake of complete transparency, BakedGoods is maintained by this guy right here :) .


Use PouchDB.

PouchDB is an open-source JavaScript database inspired by Apache CouchDB that is designed to run well within the browser.

It helps building applications that works online as well as offline.

Basically, it stores the last fetched data in the in-browser database (uses IndexedDB, WebSQL under the hood) and then syncs again when the network gets active.