1

I'm trying to get local storage data using this code but it's not working.

localStorageData = {
        id: localStorage.getItem("id"),
        token: localStorage.getItem("token"),
};

This code is inside getStaticProps().

juliomalves
  • 42,130
  • 20
  • 150
  • 146

1 Answers1

1

Actually you can not do such thing, due to the fact that getStaticProps() function gets called in server and we dont have access to Web Api's like localStorage in the server . they are accessible only in browser.

Moein Moeinnia
  • 1,945
  • 3
  • 10
  • 26