title: How i can access my window.localStorage in NextJs
body: <p>I'm studying nextjs and I came across a problem, I'm saving a jwt in localstorage and I created a function to receive the component I want to return (the page), this function needs to check if there is a token in localstorage, if it exists it returns the component , if it does not exist it redirects the user. I've already made code similar to this in other applications (without nextjs) and the code runs fine but with the next I'm having the following error:</p>
  <p>Server Error
  ReferenceError: window is not defined
  This error happened while generating the page. Any console logs will be displayed in the terminal window.</p>
  <p>Basically I don't have access to the window. How can I access the window? Is there a better way to generate private routes in nextjs manually?</p>
  <p><a href="https://i.stack.imgur.com/VNd4r.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VNd4r.png" alt="enter image description here" /></a></p>
  <p>Here's how I'm doing to make it a private route on the desired component:
  <a href="https://i.stack.imgur.com/twOha.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/twOha.png" alt="enter image description here" /></a></p>