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

586
Views
How do I access localStorage on getServerSideProps?

I'm building a next js application. I have implemented jwt in it. So whenever the user request the data from the database, a middleware is called, checks if the req.body.token and validates it. if it is, then server responds with the data else redirect the user to login.js and the token from the localstorage is get removed. So my question is, Is something wrong with this approach? Secondly, if I can't have access to localStorage how do I validate user on each request? I know I can do it by making fetch api call in useEffect from the client side. but I want to render the page on server side. is there something I should know?

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

0

You can't because getServerSideProps always runs on the server and localStorage is part of the window object which is only available in the browser

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!