Skip to content

How can I use zustand persist with indexeddb? #1721

Answered by fredericrous
CherphAlt asked this question in Q&A
Discussion options

You must be logged in to vote

with Remix I insure indexeddb is opened by putting in my clientLoader a code like this

  const dbExists = await new Promise(resolve => {
    const request = indexedDB.open('app-storage')
    request.onsuccess = event => {
      resolve(true)
    }
    request.onerror = event => {
      resolve(false)
    }
  })
  const apps = dbExists ? selectApps(useAppsStore.getState()) : []

Replies: 5 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@fredericrous
Comment options

Answer selected by dbritto-dev
@KingXP-Pythoner
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
6 participants