Skip to content

Vite SSR crashes with localStorage #2639

Answered by omridevk
omridevk asked this question in Q&A
Discussion options

You must be logged in to vote

I will try to add this code for now:

try {
      return window.sessionStorage
    } catch (e) {
      if (import.meta.env?.MODE !== 'production') {
        if (typeof window !== 'undefined') {
          console.warn(e)
        }
      }
      return undefined
    }

when I create the sessionStorage.

Replies: 3 comments 8 replies

Comment options

You must be logged in to vote
6 replies
@omridevk
Comment options

@omridevk
Comment options

@dai-shi
Comment options

@omridevk
Comment options

@dai-shi
Comment options

Comment options

You must be logged in to vote
1 reply
@omridevk
Comment options

Comment options

You must be logged in to vote
1 reply
@omridevk
Comment options

Answer selected by omridevk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants