14 lines
436 B
TypeScript
14 lines
436 B
TypeScript
import { StateStorage } from "zustand/middleware";
|
|
import { get, set, del } from "idb-keyval";
|
|
|
|
export const zustandIndexDBStorage: StateStorage = {
|
|
getItem: async (name: string): Promise<string | null> => {
|
|
return (await get(name)) || null;
|
|
},
|
|
setItem: async (name: string, value: string): Promise<void> => {
|
|
await set(name, value);
|
|
},
|
|
removeItem: async (name: string): Promise<void> => {
|
|
await del(name);
|
|
},
|
|
}; |