Skip to content

Latest commit

 

History

History
35 lines (23 loc) · 673 Bytes

File metadata and controls

35 lines (23 loc) · 673 Bytes
category
@Integrations

useIDBKeyval

Wrapper for idb-keyval.

Install idb-keyval as a peer dependency

npm install idb-keyval

Usage

import { useIDBKeyval } from '@vueuse/integrations/useIDBKeyval'

// bind object
const storedObject = useIDBKeyval('my-idb-keyval-store', { hello: 'hi', greeting: 'Hello' })

// update object
storedObject.value.hello = 'hola'

// bind boolean
const flag = useIDBKeyval('my-flag', true) // returns Ref<boolean>

// bind number
const count = useIDBKeyval('my-count', 0) // returns Ref<number>

// delete data from idb storage
storedObject.value = null