Shared storage
The SharedStorage interface of the Shared Storage API represents the shared storage for a particular origin, defining methods to write data to the shared storage.
SharedStorage is the base class for:
WindowSharedStorage, accessed via Window.sharedStorage.
WorkletSharedStorage, accessed via SharedStorageWorkletGlobalScope.sharedStorage.
Browser support
| Feature | Desktop | Mobile | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
SharedStorage Deprecated | 126 | 126 | | | 126 | |
sharedStorageWritable Deprecated | 126 | 126 | | | 126 | |
sharedStorageWritable Deprecated | 126 | 126 | | | 126 | |
append Deprecated The append() method of the SharedStorage interface appends a string to the value of an existing key-value pair in the current origin's shared storage. | 126 | 126 | | | 126 | |
clear Deprecated The clear() method of the SharedStorage interface clears the current origin's shared storage, removing all data from it. | 126 | 126 | | | 126 | |
createWorklet Deprecated | 126 | 126 | | | 126 | |
delete Deprecated The delete() method of the SharedStorage interface deletes an existing key-value pair from the current origin's shared storage. | 126 | 126 | | | 126 | |
get Deprecated | 126 | 126 | | | 126 | |
run Deprecated | 126 | 126 | | | 126 | |
selectURL Deprecated | 126 | 126 | | | 126 | |
set Deprecated The set() method of the SharedStorage interface either stores a new key-value pair in the current origin's shared storage or updates an existing one. | 126 | 126 | | | 126 | |
worklet Deprecated | 126 | 126 | | | 126 | |
SharedStorageWorklet Deprecated The SharedStorageWorklet interface of the Shared Storage API represents the shared storage worklet for the current origin. | 126 | 126 | | | 126 | |
run Deprecated | 126 | 126 | | | 126 | |
selectURL Deprecated | 126 | 126 | | | 126 | |
SharedStorageWorkletGlobalScope Deprecated The SharedStorageWorkletGlobalScope interface of the Shared Storage API represents the global scope of a SharedStorageWorklet module. | 126 | 126 | | | 126 | |
register Deprecated The register() method of the SharedStorageWorkletGlobalScope interface registers an SharedStorageOperation defined inside the current worklet module. | 126 | 126 | | | 126 | |
sharedStorage Deprecated The context read-only property of the SharedStorageWorkletGlobalScope interface contains a WorkletSharedStorage object instance, which represents the shared storage for a particular origin as exposed to a worklet context. | 126 | 126 | | | 126 | |
sharedStorage Deprecated The global read-only sharedStorage property returns the WindowSharedStorage object for the current origin. This is the main entry point for writing data to shared storage using the Shared Storage API. | 126 | 126 | | | 126 | |
Syntax
window.sharedStorage
.set("ab-testing-group", "0")
.then(() => console.log("Value saved to shared storage")); Use cases
-
Using Shared storage
The SharedStorage interface of the Shared Storage API represents the shared storage for a particular origin, defining methods to write data to the shared storage.
Cautions
- Limited browser support. Check compatibility before use.
Implementation notes
- Some APIs require a secure context (HTTPS) or user activation. Check the requirements before use.