शब्दकोश · वेब डेवलपमेंट

Local Storage

Local storage is a browser feature that saves small key-value strings on the user's device, persisting across page reloads and browser restarts until cleared.

अपडेट: अक्टूबर 6, 2026

Local storage is part of the Web Storage API. It lets JavaScript save key-value pairs, as strings, in the browser for a specific origin with no expiry date. Typical capacity is about 5 MB per origin, though it varies.

Why it matters

It is a simple way to remember preferences, drafts or UI state without server round trips. It is not secure storage: any script running on the page can read it, so a cross-site scripting flaw exposes everything inside. Unlike cookies, its contents are never sent automatically with requests.

Example

localStorage.setItem('theme', 'dark');
const theme = localStorage.getItem('theme'); // 'dark'
localStorage.setItem('prefs', JSON.stringify({ lang: 'en' }));
localStorage.removeItem('theme');

Objects must be converted to strings with JSON.stringify.

Common mistakes

  • Storing session tokens or personal data there. Prefer HttpOnly cookies for authentication.
  • Assuming it always works: private browsing or blocked storage can throw errors.
  • Treating it as a database. It is synchronous and blocks the main thread.

Get notified when this term updates

Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.

यह पेज सामान्य जानकारी है, जिसे हमारी संपादकीय टीम ने लिखा है और दस्तावेज़ीकरण बदलने पर अपडेट किया जाता है। सर्वर और प्रदाता अलग-अलग होते हैं, इसलिए बदलाव पहले सुरक्षित तरीके से जाँचें। देखें: संपादकीय नीति और अस्वीकरण.