This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useStorageAsync } from "@vueuse/core"; | |
import { get, set, del } from "idb-keyval"; | |
export const STORAGE_KEY_PREFIX = "app.session."; | |
// eslint-disable-next-line @typescript-eslint/no-explicit-any | |
export function useIdbStorage<T = any>(key: string, initialValue: T) { | |
return useStorageAsync(`${STORAGE_KEY_PREFIX}${key}`, initialValue, { | |
async getItem(key: string) { | |
return (await get<string>(key)) ?? null; |
OlderNewer