🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

vue-persistent-storage-manager

Package Overview
Dependencies
Maintainers
1
Versions
115
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-persistent-storage-manager

Vue plugin that wraps the StorageManager API and provides the state of the persistent-storage permission alongside a storage estimate.

3.0.16
latest
Source
npm
Version published
Weekly downloads
21
16.67%
Maintainers
1
Weekly downloads
 
Created
Source

vue-persistent-storage-manager

CI NPM Coverage

npm peer dependency version MIT

Vue plugin that wraps the StorageManager API and provides the state of the persistent-storage permission alongside a storage estimate.

Features

  • 🔧 Persistent storage: Request and monitor the persistent-storage permission.
  • 💽 Storage estimate: Get storage quota and usage estimates.
  • 🔁 Reactive: Provides observable state using Vue's reactivity
  • ✔️ SSR: Supports server-side-rendering by validating the availability of the StorageManager API.

Installation

# yarn
$ yarn add vue-persistent-storage-manager

# npm
$ npm install vue-persistent-storage-manager

Usage

import Vue from 'vue'
import { VuePersistentStorageManager } from 'vue-persistent-storage-manager'

Vue.use(VuePersistentStorageManager, { watchStorage: true })

Options are not required. In this case, watchStorage will default to false.

Note: If watchStorage is set to true, the functions localStorage.setItem and localStorage.removeItem are replaced by functions that update the StorageEstimate. The original functions will still be called and are available as localStorage.originalSetItem and localStorage.originalRemoveItem

<template>
  <div>
    <button
      :disabled="!$storageManager.isAvailable || $storageManager.isPersistent"
      @click="$storageManager.requestPersistentStorage()"
    >
      {{
        $storageManager.isPersistent
          ? 'Persistence granted'
          : 'Request persistence'
      }}
    </button>
    <p>{{ (100 * $storageEstimate.usage) / $storageEstimate.quota }}%</p>
    <p>{{ $storageEstimate.usage / 1000000 }}MB</p>
  </div>
</template>

Nuxt

  • Create the file plugins/persistentStorageManager.ts with the following content.
import Vue from 'vue'
import { VuePersistentStorageManager } from 'vue-persistent-storage-manager'

export default () => {
  Vue.use(VuePersistentStorageManager, { watchStorage: true })
}
  • Update the plugins array in nuxt.config.js.
export default {
  plugins: [{ src: '~/plugins/persistentStorageManager.ts' }],
}

Development

# install dependencies
$ yarn install

# build for production
$ yarn build

# lint project files
$ yarn lint

# run tests
$ yarn test

License

MIT - Copyright © Jan Müller

Keywords

vue

FAQs

Package last updated on 11 Jun 2025

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