Storing and Retrieving Data in Next.js Using LocalStorage and TypeScript
Too Long; Didn't Read
Persisting data in Next.js using localStorage is very frustrating, and I have read many posts where other developers use other libraries or cookies to accomplish the same effect as localStorage. In my use case, I needed the localStorage to store the user preference without creating a modal and making API requests to POST and GET. We'll create a colour selector with a dropdown menu, so we can select the colour they want, and store whatever option we select. After the page refreshes, the data still persist.