SharedStorage: delete() method

Deprecated
To be removed

This feature is pending removal from browsers. Using it now may lead to broken functionality in future updates. Following the announcement that Chrome will maintain its current approach to third-party cookies, Chrome decided to withdraw certain Privacy Sandbox features including the shared storage.

Non-standard: This feature is not standardized. We do not recommend using non-standard features in production, as they have limited browser support, and may change or be removed. However, they can be a suitable alternative in specific cases where no standard option exists.

The delete() method of the SharedStorage interface deletes an existing key-value pair from the current origin's shared storage.

Syntax

js
delete(key)

Parameters

key

A string representing the key of the key-value pair you want to delete.

Return value

A Promise that fulfills with undefined.

Exceptions

Note: If the key-value pair doesn't exist in the shared storage, no error is thrown — the operation still fulfills with undefined.

Note: In the case of WindowSharedStorage, if the delete() operation doesn't successfully write to the database for a reason other than shared storage not being available, no error is thrown — the operation still fulfills with undefined.

Examples

js
window.sharedStorage
  .delete("ab-testing-group")
  .then(() => console.log("Value deleted"));

Specifications

This feature does not appear to be defined in any specification.

Browser compatibility

See also