Florian Margaine
Florian Margaine

Reputation: 60825

localStorage in chrome extensions - Extension or page storage?

If I use localStorage in a Google Chrome extension, is it the storage of the current webpage, or is it the storage of the extension?

Alternatively, how can I reach each localStorage independently?

Upvotes: 2

Views: 719

Answers (1)

Some Guy
Some Guy

Reputation: 16210

Depends on where you use it. If you use it on the background or options page, it is of the extension, and it is shared. If it is from a content script, it is on the specific page. You can't reach the localStorage of each page at will, so if you want to do that, you should send a request to the background and store it in the extension's storage.

Note that if you're using the extension's storage, you may want to use chrome.storage instead.

Upvotes: 5

Related Questions