0.0.1 • Published 3 years ago

use-browser-storage-limit v0.0.1

Weekly downloads
4
License
MIT
Repository
github
Last release
3 years ago

use-browser-storage-limit Maintainability

React Hook to detect the browser storage limit

Getting Started

Installation

$ npx use-browser-storage-limit

Basic Usage

import useBrowserStorageLimit from "use-browser-storage-limit";

function App() {
  const { loading, quota, usage, percentage, error } = useBrowserStorageLimit()

  return (
    <div className="App">
      {loading ? <p>Loading...</p> : error ? <div><p>Error: {error}</p></div> : <div>
        <p>Total Quota: {quota}</p>
        <p>Total Usage: {usage}</p>
        <p>Percentage Used: {percentage}%</p>
      </div>}
    </div>
  );
}

Output

NameTypeDefaultDescription
loadingBooleanfalseLoader
quotaNumber0Total space of the Storage
usageNumber0Used space of the Storage
percentageNumber0Percentage of Storage used
errorString() => {}Async Storage clear item method
getQuotafunction() => { quota, usage }Async function to get the estimate of the Storage

Contribution

Questions

Feel free to contact me or create an issue