storage-inspector-js
TypeScript icon, indicating that this package has built-in type declarations

1.0.9 • Public • Published

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

name type params default description
BROWSER string it will provide the browser name i.e. Brave, Chrome, Firefox, Safari, Internet Explorer Edge, Samsung Browser, UC Browser, Opera, Unknown.
getStorageUsageAndQuota function get storage usage & quota { raw: { usage: 180670, quota: 24090080 }, baked: { usage: "230KiB", quota: "980MiB" } }
clearSiteData function indexDBName required for firefox, reload required clears site data which includes all browser storage. Set reload params to true, to reload the site once storage is clear.

Package Sidebar

Install

npm i storage-inspector-js

Weekly Downloads

37

Version

1.0.9

License

ISC

Unpacked Size

13.2 kB

Total Files

4

Last publish

Collaborators

  • atul15r