Store.js Tutorial- A Javascript Storage Library

Heard of cookies? then you also know about cookies and its limitations as it can store only 4KB of user data at a time. So, to overcome the problem Store.js comes to the rescue.

Store.js is a localStorage wrapper and a cross-browser persistent storage library that stores values in the browser itself. It does not take the use of cookies or flash and just take the use of localStorage, globalStorage and userData.

Check this Out: How to Create Browser Based Notifications and Dialogues

As per the man behind store.js, it was launched in 2010 and has been widely used by various companies like CNN.com to store data locally.

store.js

Since we were talking about the localStorage, so let’s learn about it first.

What is a localStorage?

LocalStorage enables you to store data locally on your computer. It works similar to cookies but it is far better than cookies. Usually, data is lost when the computer is shut down or browser is closed while storing data with cookies but the best part with localStorage is that even after a power interruption or you accidentally closed your browser the data will remain safe and secured in the localStorage.

So basically store.js is a best local storage javascript library example that is useful for storing a wide range of data in the browser.

Recommended Readings:

How to use Store.js?

It is easy to get started with store.js you need the simple Store.js API for cross-browser local storage.

Want to go deeper in Store.js, you first have to download the js files of the store.js library from the

Then you first have to download the js files of the store.js library from the GitHub Repository.

or

Store.js CDN:

You can also use the CDN of the store.js library to directly embed it in your webpage.

Now you have embedded the javascript library of store.js in your web page. Let’s write some code to go further in store.js

It is known that Items in store.js are stored in groups called stores.

Now you first have to create a new store. It’s like creating a new object of the Store class.

This will create a new store for you in store.js

Now want to store items in the new store created.

Now of you want to add more items to the store then you can do that also:

You can also store an array of numbers on the store:

Now coming to some important points of store.js

More Readings:

List of Supported Browsers for Store.js

  • Tested on IE6+
  • Tested on iOS 8+
  • Tested on Android 4+
  • Tested on Firefox 4+
  • Tested on Chrome 27+
  • Tested on Safari 5+
  • Tested on Opera 11+
  • Tested on Node

Now there are browsers that are yet not supporting the store.js javascript library, If you want yo support all browsers (including IE 6, IE 7, Firefox 4, etc.), you have to use require(‘store’) (alias for require(‘store/dist/store.legacy’)) or store.legacy.min.js.

That was interesting and now you have learned the basics of store.js and its time to get started with Store.js using the Store.js API.

(Visited 153 times, 1 visits today)
Share is Caring...!

Leave a Reply