useIDBKeyval 
idb-keyvalのラッパー。
デモ 
@vueuse/integrationsアドオンで利用可能です。idb-keyvalをピア依存関係としてインストールします 
bash
npm install idb-keyval@^6使い方 
ts
import { useIDBKeyval } from '@vueuse/integrations/useIDBKeyval'
// bind object
const { data: storedObject, isFinished } = 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>
// awaiting IDB transaction
await count.set(10)
console.log('IDB transaction finished!')
// delete data from idb storage
storedObject.value = null型定義 
typescript
export interface UseIDBOptions extends ConfigurableFlush {
  /**
   * Watch for deep changes
   *
   * @default true
   */
  deep?: boolean
  /**
   * On error callback
   *
   * Default log error to `console.error`
   */
  onError?: (error: unknown) => void
  /**
   * Use shallow ref as reference
   *
   * @default false
   */
  shallow?: boolean
  /**
   * Write the default value to the storage when it does not exist
   *
   * @default true
   */
  writeDefaults?: boolean
}
export interface UseIDBKeyvalReturn<T> {
  data: RemovableRef<T>
  isFinished: Ref<boolean>
  set: (value: T) => Promise<void>
}
/**
 *
 * @param key
 * @param initialValue
 * @param options
 */
export declare function useIDBKeyval<T>(
  key: IDBValidKey,
  initialValue: MaybeRefOrGetter<T>,
  options?: UseIDBOptions,
): UseIDBKeyvalReturn<T>ソース 
貢献者 
変更履歴 
v12.0.0-beta.1 2024年11月21日v10.9.0 2024年2月27日v10.8.0 2024年2月20日a086e - fix: より厳密な型v10.4.0 2023年8月25日v10.0.0-beta.4 2023年4月13日4d757 - feat(types)!: MaybeComputedRef を MaybeRefOrGetter に名称変更0a72b - feat(toValue): resolveUnref を toValue にリネームv10.0.0-beta.0 2023/03/14 にリリースv9.6.0 2022/11/22 にリリースv9.5.0 2022/11/09 にリリース