storage.sync

Represents the sync storage area. Items in sync storage are synced by the browser. The data is then available on all instances of the browser the user is logged into (for example, when using a Mozilla account on desktop versions of Firefox or a Google account on Chrome) across different devices.

For desktop Firefox, a user must have Add-ons selected in the "Sync" section in "about:preferences". Firefox for Android does not synchronize data with the user's account. See Firefox bug 1625257.

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 can store in the sync storage area.

512

If an extension attempts to store items that exceed these limits, calls to storage.sync.set() are rejected with an error. An extension can use storage.sync.getBytesInUse() to find out how much of its quota is in use.

Synchronization process

In Firefox, extension data is synced every 10 minutes or whenever the user selects Sync Now (in Settings > Sync or from the Mozilla account icon). When the browser performs a sync, for each key stored, it:

  • compares the value on the server with the value at the last sync; if they are different, the value from the server is written to the key in the browser's sync storage.
  • compares the browser's sync storage values with the value on the server; if they are different, writes the browser's key value to the server.

This means that, for each key, a change on the server takes precedence over a change in the browser's sync storage.

This mechanism is generally OK for data such as user preferences or other global settings changed by the user.

However, a key's value can be updated on one browser and synchronized then updated on a second browser before the second browser is synchronized, resulting in the local update being overwritten during sync. This mechanism is, therefore, not ideal for data aggregated across devices, such as a count of page views or how many times an option is used. To handle such cases, use storage.sync.onChanged to listen for sync updates from the server (for example, a count of page views on another browser instance). Then adjust the value locally to take the remote value into account (for example, update the total views based on the remote count and new local count).

Methods

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

storage.sync.get()

Retrieves one or more items from the storage area.

storage.sync.getBytesInUse()

Gets the amount of storage space (in bytes) used for one or more items in the storage area.

storage.sync.getKeys()

Retrieves the keys of all items in the storage area.

storage.sync.set()

Stores one or more items in the storage area. If the item exists, its value is updated.

storage.sync.remove()

Removes one or more items from the storage area.

storage.sync.clear()

Removes all items from the storage area.

Events

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

storage.sync.onChanged

Fires when one or more items in the storage area change.

Example extensions

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Firefox for Android
Safari on iOS
sync
Chrome – Full support
Chrome 19 (Release date: 2012-05-15)
footnote Full support
Edge – Full support
Edge 15 (Release date: 2017-04-05)
footnote Full support
Firefox – Full support
Firefox 53 (Release date: 2017-04-19)
footnote
footnote Before version 79, storage quota limits are not enforced.
Opera – No support
Opera
footnote No support
Safari – Partial support
Safari 14 (Release date: 2020-09-16)
footnote Partial support
footnote Safari does not sync items saved in the sync storage area, i.e. it behaves the same as the local storage area.
footnote Safari 15 and 15.1 erroneously store sync items in the local storage area. If unable to locate sync items, check for sync items in the local storage area and do a one-time migration to the sync storage area.
Firefox for Android – Partial support
Firefox for Android 53 (Release date: 2017-04-19)
footnote Partial support
footnote Data isn't synchronized with the user's Mozilla account.
footnote Storage quota limits are not enforced.
footnote See bug 162525
Safari on iOS – Partial support
Safari on iOS 15 (Release date: 2021-09-20)
footnote Partial support
footnote Safari does not sync items saved in the sync storage area, i.e. it behaves the same as the local storage area.
footnote Safari 15 and 15.1 erroneously store sync items in the local storage area. If unable to locate sync items, check for sync items in the local storage area and do a one-time migration to the sync storage area.
clear
Chrome – Full support
Chrome 19 (Release date: 2012-05-15)
footnote Full support
Edge – Full support
Edge 15 (Release date: 2017-04-05)
footnote Full support
Firefox – Full support
Firefox 53 (Release date: 2017-04-19)
footnote Full support
Opera – No support
Opera
footnote No support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote Full support
Firefox for Android – Partial support
Firefox for Android 53 (Release date: 2017-04-19)
footnote Partial support
footnote Data isn't synchronized with the user's Mozilla account.
footnote See bug 162525
Safari on iOS – Full support
Safari on iOS 15 (Release date: 2021-09-20)
footnote Full support
get
Chrome – Full support
Chrome 19 (Release date: 2012-05-15)
footnote Full support
Edge – Full support
Edge 15 (Release date: 2017-04-05)
footnote Full support
Firefox – Full support
Firefox 53 (Release date: 2017-04-19)
footnote Full support
Opera – No support
Opera
footnote No support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote Full support
Firefox for Android – Partial support
Firefox for Android 53 (Release date: 2017-04-19)
footnote Partial support
footnote Data isn't synchronized with the user's Mozilla account.
footnote See bug 162525
Safari on iOS – Full support
Safari on iOS 15 (Release date: 2021-09-20)
footnote Full support
Supports empty key
Chrome – Full support
Chrome 19 (Release date: 2012-05-15)
footnote Full support
Edge – Full support
Edge 15 (Release date: 2017-04-05)
footnote Full support
Firefox – Full support
Firefox 53 (Release date: 2017-04-19)
footnote Full support
Opera – No support
Opera
footnote No support
Safari – Full support
Safari 18 (Release date: 2024-09-16)
footnote Full support
Firefox for Android – Full support
Firefox for Android 53 (Release date: 2017-04-19)
footnote Full support
Safari on iOS – Full support
Safari on iOS 18 (Release date: 2024-09-16)
footnote Full support
getBytesInUse
Chrome – Full support
Chrome 19 (Release date: 2012-05-15)
footnote Full support
Edge – Full support
Edge 15 (Release date: 2017-04-05)
footnote Full support
Firefox – Full support
Firefox 78 (Release date: 2020-06-30)
footnote Full support
Opera – No support
Opera
footnote No support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote Full support
Firefox for Android – Full support
Firefox for Android 79 (Release date: 2020-07-28)
footnote Full support
Safari on iOS – Full support
Safari on iOS 15 (Release date: 2021-09-20)
footnote Full support
getKeys
Chrome – Full support
Chrome 130 (Release date: 2024-10-15)
footnote Full support
Edge – Full support
Edge 130 (Release date: 2024-10-17)
footnote Full support
Firefox – Full support
Firefox 143 (Release date: 2025-09-16)
footnote Full support
Opera – No support
Opera
footnote No support
Safari – Full support
Safari 18.4 (Release date: 2025-03-31)
footnote Full support
Firefox for Android – Partial support
Firefox for Android 143 (Release date: 2025-09-16)
footnote Partial support
footnote Data isn't synchronized with the user's Mozilla account.
footnote See bug 162525
Safari on iOS – Full support
Safari on iOS 18.4 (Release date: 2025-03-31)
footnote Full support
onChanged
Chrome – Full support
Chrome 73 (Release date: 2019-03-12)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 101 (Release date: 2022-05-31)
footnote Full support
Opera – No support
Opera
footnote No support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote Full support
Firefox for Android – Full support
Firefox for Android 101 (Release date: 2022-05-31)
footnote Full support
Safari on iOS – Full support
Safari on iOS 15 (Release date: 2021-09-20)
footnote Full support
remove
Chrome – Full support
Chrome 19 (Release date: 2012-05-15)
footnote Full support
Edge – Full support
Edge 15 (Release date: 2017-04-05)
footnote Full support
Firefox – Full support
Firefox 53 (Release date: 2017-04-19)
footnote Full support
Opera – No support
Opera
footnote No support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote Full support
Firefox for Android – Partial support
Firefox for Android 53 (Release date: 2017-04-19)
footnote Partial support
footnote Data isn't synchronized with the user's Mozilla account.
footnote See bug 162525
Safari on iOS – Full support
Safari on iOS 15 (Release date: 2021-09-20)
footnote Full support
Supports empty key
Chrome – Full support
Chrome 19 (Release date: 2012-05-15)
footnote Full support
Edge – Full support
Edge 15 (Release date: 2017-04-05)
footnote Full support
Firefox – Full support
Firefox 53 (Release date: 2017-04-19)
footnote Full support
Opera – No support
Opera
footnote No support
Safari – Full support
Safari 18 (Release date: 2024-09-16)
footnote Full support
Firefox for Android – Full support
Firefox for Android 53 (Release date: 2017-04-19)
footnote Full support
Safari on iOS – Full support
Safari on iOS 18 (Release date: 2024-09-16)
footnote Full support
set
Chrome – Full support
Chrome 19 (Release date: 2012-05-15)
footnote Full support
Edge – Full support
Edge 15 (Release date: 2017-04-05)
footnote
footnote storage is limited to 1MB per value.
Firefox – Full support
Firefox 53 (Release date: 2017-04-19)
footnote Full support
Opera – No support
Opera
footnote No support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote Full support
Firefox for Android – Partial support
Firefox for Android 53 (Release date: 2017-04-19)
footnote Partial support
footnote Data isn't synchronized with the user's Mozilla account.
footnote Storage quota limits are not enforced.
footnote See bug 162525
Safari on iOS – Full support
Safari on iOS 15 (Release date: 2021-09-20)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
No support
No support
See implementation notes.

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