Socket
Book a DemoInstallSign in
Socket

storage-inspector-js

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

storage-inspector-js

clear site data, get storage usage & quota.

latest
Source
npmnpm
Version
1.0.9
Version published
Maintainers
1
Created
Source

Browser Storage Inspector

storage-inspector-js library helps to clear site data & provides storage usage & quota.

npm version install size npm bundle size npm downloads npm version

Browser Support

Brave Edge Firefox Google Chrome IE Opera Safari

Installation

 # If you use npm:
 npm i storage-inspector-js

 # If you use yarn:
 yarn add storage-inspector-js


 ES6 Usage
 import { BROWSER, getStorageUsageAndQuota, clearSiteData } from 'storage-inspector-js';

 Commonjs Usage
 var { BROWSER, getStorageUsageAndQuota, clearSiteData } = require('storage-inspector-js');

Usage


import React, {useEffect} from 'react';
import { BROWSER, getStorageUsageAndQuota, clearSiteData, STORAGE_INFO } from 'storage-inspector-js';

const App = () => {
  const [storageInfo, setStorageInfo] = useState<STORAGE_INFO>()

 useEffect(()=>{
  (async()=>{
     const res= await getStorageUsageAndQuota();
     setStorageInfo(res)
    })()
  },[])


  const clearStorage = async () => {
    await clearSiteData({ reload: true})

    // to delete specific IndexDB
    await clearSiteData({ indexDBName: "DBName", reload: true})

  }

  return (
   <div>
    <h3>BROWSER: {BROWSER}</h3>
    <p>Storage Info: {storageInfo.baked.usage/storageInfo.baked.quota}</p>
    <button onClick={clearStorage}>Clear Site Data</button>
   </div>
  );
};

export default App;

Props

nametypeparamsdefaultdescription
BROWSERstringit will provide the browser name i.e. Brave, Chrome, Firefox, Safari, Internet Explorer Edge, Samsung Browser, UC Browser, Opera, Unknown.
getStorageUsageAndQuotafunctionget storage usage & quota { raw: { usage: 180670, quota: 24090080 }, baked: { usage: "230KiB", quota: "980MiB" } }
clearSiteDatafunctionindexDBName required for firefox, reload requiredclears site data which includes all browser storage. Set reload params to true, to reload the site once storage is clear.

Keywords

Javascript Clear Site Data

FAQs

Package last updated on 07 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts