future-proof package for migrating persisted zustand stores #2082
Unanswered
rob-gordon
asked this question in
Show and tell
Replies: 1 comment 2 replies
-
Hello export const IdbStorage: StateStorage = {
getItem: async (name) => {
// Exit early on server
if (typeof indexedDB === "undefined") {
return null;
}
const value = await get(name);
console.log("load indexeddb called");
return value || null;
},
setItem: async (name, value) => {
// Exit early on server
if (typeof indexedDB === "undefined") {
return;
}
return set(name, value);
},
removeItem: async (name) => {
// Exit early on server
if (typeof indexedDB === "undefined") {
return;
}
await del(name);
}
}; I am not sure if your plugin is actually meant to archive this use case |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I wrote a library for migrating data and I tailored the API to work well with the
persist
middleware. It's called future-proof.Here's what a full example looks like with zustand:
That's it! I use zustand persisted stores in so many projects, which is what inspired me to abstract this into a package. I hope it helps other people as well.
Beta Was this translation helpful? Give feedback.
All reactions