I am using NextJS 12. I am trying to get local storage object. When I use localstorage inside getServerSideProps
I get an error like this ReferenceError: localStorage is not defined
. I tried to use it outside the function as well but I still get this error. Is there any way to use it inside getServerSideProps
.
export async function getServerSideProps({ query }) {
const id = query.id;
const getData = JSON.parse(localStorage.getItem("form"));
console.log(getData)
return {
props: {},
}