W3cubDocs

/Web APIs

SharedStorage: clear() method

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The clear() method of the SharedStorage interface clears the current origin's shared storage, removing all data from it.

Syntax

clear()

Parameters

None.

Return value

A Promise that fulfills with undefined.

Exceptions

Note: In the case of WindowSharedStorage, if the clear() 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

window.sharedStorage.clear().then(() => console.log("Shared storage cleared"));

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Opera Safari Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet WebView Android WebView on iOS
clear 126 126 No 112 No 126 No 83 No 28.0 126 No

See also

© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/SharedStorage/clear