-1

I am developing an extension ,I am using localStorage and now it seems like i will have huge amount of data stored in it. I have read about different approaches like WebSQL and IndexedDB , I am not sure which is best to use . Is localStorage good for this purpose ?

Thank you

Maxim Toyberman
  • 1,906
  • 1
  • 20
  • 35

3 Answers3

1

localStorage capacity is browser specific and the standards don't seem to specify how much it should be. So different browsers are free to chose their own. By default, it used to be about 10MB for Chrome. See What is the max size of localStorage values?

Users can change the values in the browser settings.

This site seems to run a web storage test on your browser http://dev-test.nemikor.com/web-storage/support-test/ For my Firefox desktop version it correctly reported localStorage of 5MB, I'm assuming this web storage test works fine.

Community
  • 1
  • 1
Ravi R
  • 1,692
  • 11
  • 16
1

I have developed a chrome extension before and I used chrome.storage.local. If you are developing an extension for chrome only, the best choice would be that. It has support for large data, you just have to set the unlimitedStorage permission.

David
  • 1,139
  • 3
  • 10
  • 16
1

Here is the way i used chrome.storage in my packaged chrome application. It supports large data

  1. I Added storage permissions in my manifest.json
  2. I used chrome.storage.local.set in my js to store data in my browser local storage

manifest.json

"permissions": [
        "notifications",
        "storage"
    ],

script.js- to set the data to local storage

 chrome.storage.local.set({
                          'loginToken': response.data.loginToken,
                           'role':response.data.role
                      }, function() {
                       // console.log("The value stored was: " + loginToken);
                   });

script.js - to get the data from local storage

chrome.storage.local.get('loginToken', function(result) {
                                if (!(result.loginToken)) {
                                    alert("please login with your details!!");
                                }

                            })

if we build hosted chrome app. we can use window.localStorage please refer to this document for the further details. https://developer.chrome.com/extensions/storage

Ravi Teja Kumar Isetty
  • 1,559
  • 4
  • 21
  • 39