Chrome extensions have access to three main types of storage mechanisms.
Each is suited to different use cases and has different permissions and limitations.
chrome.storage
APIThe official Chrome extension storage API.
chrome.storage.local
chrome.storage.sync
chrome.storage.session
(Manifest V3 only)
localStorage
Synchronous (sync):
localStorage
)Asynchronous (async):
chrome.storage
, IndexedDB
)manifest.json
Storage Type | Required Permission |
---|---|
chrome.storage.* |
"storage" |
localStorage |
β No special permission |
IndexedDB |
β No special permission |
β
chrome.storage
needs the"storage"
permission in your manifest.
An origin is the combination of:
protocol + domain + port
https://example.com
is one originhttp://example.com
is a different origin
In Chrome extensions:
chrome-extension://<extension-id>
localStorage
and IndexedDB
are scoped to your extensionβs origin
β οΈ Extensions cannot access webpage storage unless explicitly allowed.
Storage | Max Size | Sync? | Async? | Recommended Use |
---|---|---|---|---|
chrome.storage.local |
~5MB+ | β | β | General storage |
chrome.storage.sync |
100KB | β | β | User preferences |
chrome.storage.session |
Session | β | β | Temporary runtime state |
localStorage |
5MB | β | β | Quick hacks or legacy fallback |
IndexedDB | Large | β | β | Large/structured data |
chrome.storage.local
for most simple needschrome.storage.sync
for synced preferences/settingschrome.storage.session
for transient stateslocalStorage
unless you really know what you're doingChallenge: What is the difference between the behavior or chrome.storage vs IndexedDB for JSON data?
Try storing the value { "key": 1 } ...