storage.sync

Represents the sync storage area. Items in sync storage are synced by the browser, and are available across all instances of that browser that the user is logged into (e.g. via Firefox sync, or a Google account), across different devices.

For Firefox a user must have Add-ons checked under the "Sync Settings" options in "about:preferences".

Note that the implementation of storage.sync in Firefox relies on the Add-on ID. If you use storage.sync, you must set an ID for your extension using the browser_specific_settings manifest.json key.

The main use case of this API is to store preferences about your extension and allow the user to sync them to different profiles.

Storage quotas for sync data

The browser enforces limits on the amount of data each extension is allowed to store in the sync area:

Name Description Value in bytes
Maximum total size The maximum total amount of data that each extension is allowed to store in the sync storage area, as measured by the JSON stringification of every value plus every key's length. 102400
Maximum item size The maximum size of any one item that each extension is allowed to store in the sync storage area, as measured by the JSON stringification of the item's value plus the length of its key. 8192
Maximum number of items The maximum number of items that each extension is allowed to store in the sync storage area.

512

If an extension attempts to store items that exceed these limits, the call to storage.sync.set() will be rejected with an error. An extension can use storage.sync.getBytesInUse() to find out how much of its maximum total quota it is currently using.

Methods

The sync object implements the methods defined on the storage.StorageArea type:

storage.StorageArea.get()
Retrieves one or more items from the storage area.
storage.StorageArea.getBytesInUse()
Gets the amount of storage space (in bytes) used one or more items being stored in the storage area.
storage.StorageArea.set()
Stores one or more items in the storage area. If the item already exists, its value will be updated.
storage.StorageArea.remove()
Removes one or more items from the storage area.
storage.StorageArea.clear()
Removes all items from the storage area.

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
sync
Yes
15
53
Before version 79, storage quota limits are not enforced.
?
No
14
Safari does not sync items saved in the sync storage area, i.e. it behaves the same as the local storage area.
?
?
No
?
?
?

Example extensions

Note: This API is based on Chromium's chrome.storage API. This documentation is derived from storage.json in the Chromium code.

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.

© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/storage/sync