files/en-us/web/api/storagemanager/persist/index.md
{{securecontext_header}}{{APIRef("Storage")}}
The persist() method of the {{domxref("StorageManager")}} interface requests permission to use persistent storage, and returns a {{jsxref('Promise')}} that resolves to true if permission is granted and bucket mode is persistent, and false otherwise. The browser may or may not honor the request, depending on browser-specific rules. (For more details, see the guide to Storage quotas and eviction criteria.)
[!NOTE] This method is not available in Web Workers, though the {{domxref("StorageManager")}} interface is.
persist()
None.
A {{jsxref('Promise')}} that resolves to a {{jsxref('Boolean')}}.
TypeError
if (navigator.storage && navigator.storage.persist) {
navigator.storage.persist().then((persistent) => {
if (persistent) {
console.log("Storage will not be cleared except by explicit user action");
} else {
console.log("Storage may be cleared by the UA under storage pressure.");
}
});
}
{{Specifications}}
{{Compat}}