We all love localStorage. It is the easiest way to persist state in a web app. You don’t need a database, you don’t need a backend, and the API is dead simple: setItem and getItem.

But if you’ve built enough production apps, you know localStorage has two major flaws that eventually come back to bite you:

It’s Immortal: Data stays there forever. Unless you manually write code to delete it, your user’s disk fills up with stale data from three years ago. 1.

It’s Exposed: Open the DevTools "Application" tab, and anyone can read (and edit) your application state in plain text.

I built a lightweight, zero-dependency TypeScript package to solve exactly these problems.

Meet @kushalst/local-storage-expiry

#…

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help