Back to Content

Window: sharedStorage property

files/en-us/web/api/window/sharedstorage/index.md

latest1009 B
Original Source

{{APIRef("Shared Storage API")}}{{SecureContext_Header}}{{deprecated_header}}

The global read-only sharedStorage property returns the {{domxref("WindowSharedStorage")}} object for the current origin. This is the main entry point for writing data to shared storage using the Shared Storage API.

[!NOTE] sharedStorage is not available inside workers. It is implemented by {{domxref("Window")}} and is also available in shared storage worklets (see {{domxref("SharedStorageWorkletGlobalScope.sharedStorage")}}, which returns {{domxref("WorkletSharedStorage")}}).

Value

A {{domxref("WindowSharedStorage")}} object instance.

Examples

js
window.sharedStorage
  .set("ab-testing-group", "0")
  .then(() => console.log("Value saved to shared storage"));

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also