Pocketstore – A Modern Way to Use localStorage, with TTL, Encryption & SSR Support

As developers, we’ve all been there. You’re building a frontend app — maybe with React, maybe just vanilla JS — and you need to persist some data. A token here, a draft form value there, a session timer for the user’s login… You reach for localStorage or sessionStorage, right? It’s built-in, quick, and doesn’t require cookies or a server. But then reality sets in: You need to expire items after a while. Whoops, there’s no TTL. You want to avoid key collisions across features. Now you’re prefixing keys manually. You suddenly realize you need to support SSR, but window is undefined on the server. You’re handling sensitive tokens, but there’s no way to encrypt them. What was supposed to be easy starts looking messy. You end up with utility functions, custom wrappers, and too many try...catch blocks. That’s the pain I wanted to solve. So I built:

Apr 18, 2025 - 11:48
 0
Pocketstore – A Modern Way to Use localStorage, with TTL, Encryption & SSR Support

As developers, we’ve all been there. You’re building a frontend app — maybe with React, maybe just vanilla JS — and you need to persist some data. A token here, a draft form value there, a session timer for the user’s login…

You reach for localStorage or sessionStorage, right? It’s built-in, quick, and doesn’t require cookies or a server. But then reality sets in:

  • You need to expire items after a while. Whoops, there’s no TTL.
  • You want to avoid key collisions across features. Now you’re prefixing keys manually.
  • You suddenly realize you need to support SSR, but window is undefined on the server.
  • You’re handling sensitive tokens, but there’s no way to encrypt them.

What was supposed to be easy starts looking messy. You end up with utility functions, custom wrappers, and too many try...catch blocks.

That’s the pain I wanted to solve. So I built: