You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
14 lines
432 B
14 lines
432 B
import { StateStorage } from "zustand/middleware";
|
|
import { get, set, del } from "idb-keyval";
|
|
|
|
export const zustandIDBStorage: 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);
|
|
},
|
|
};
|