Newnessimworks.com
Glossary · Web development

localStorage

Browser key-value storage tied to the origin, persistent across tabs and sessions — useful for user preferences and small client-side caches.

Definition

In long form.

localStorage stores up to ~5–10 MB of strings per origin, accessible synchronously via JavaScript. Survives page reloads, tab close, and browser restart (until cleared). Limitations: synchronous API blocks the main thread on large reads/writes, strings only (you have to JSON.stringify objects), no expiration mechanism (you build it yourself), and accessible to any JS running on the page (XSS risk for sensitive data). For larger or async storage, IndexedDB is the better tool.

In context

We use localStorage for theme preference, dismissed banner state, and similar non-sensitive UI settings. Anything sensitive — auth tokens, PII — never goes into localStorage; that's what HttpOnly cookies are for.

Discovery first

Talk to us about your engagement.

Discovery calls are free. Scope, timelines, and pricing are quoted after we understand what you’re solving.