Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

281
Views
How to access localStorage in store/state, namely in state using Nuxt.js?

I am trying to access localStorage in the store, namely in state.
I understand that there is no access to browser methods/objects in SSR.

I'm trying to do this:

export const state = () => {
  if (process.client) {
    return {
      isAuth: localStorage.getItem('isAuth')
    }
  }
}

The development console (Vuex) is empty, there is nothing. And if so:

export const state = () => {
  if (process.client) {
    return {
      isAuth: localStorage.getItem('isAuth')
    }
  } else {
    return {
      isAuth: 'SomeData'
    }
  }
}

Then he sees the server work and isAuth = 'SomeData', but i need "client" How do I access localStorage?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You could try to get this localstorage data in mounted hook and from there commit this data to your vuex state.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!