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.
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.
The sync
object implements the methods defined on the storage.StorageArea
type:
storage.StorageArea.get()
storage.StorageArea.getBytesInUse()
storage.StorageArea.set()
storage.StorageArea.remove()
storage.StorageArea.clear()
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 |
? |
? |
? |
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