paint-brush
Storing and Retrieving Data in Next.js Using LocalStorage and TypeScriptby@rockyessel
15,060 reads
15,060 reads

Storing and Retrieving Data in Next.js Using LocalStorage and TypeScript

by Rocky Essel8mApril 18th, 2023
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

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.
featured image - Storing and Retrieving Data in Next.js Using LocalStorage and TypeScript
Rocky Essel HackerNoon profile picture
Rocky Essel

Rocky Essel

@rockyessel

Web Developer | Full-Stack Developer | Javascript | Typescript | React | NextJs | Node

0-item

STORY’S CREDIBILITY

Original Reporting

Original Reporting

This story contains new, firsthand information uncovered by the writer.

L O A D I N G
. . . comments & more!

About Author

Rocky Essel HackerNoon profile picture
Rocky Essel@rockyessel
Web Developer | Full-Stack Developer | Javascript | Typescript | React | NextJs | Node

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite