Browser Storage
Definition
Browser storage is the umbrella term for the several stores a page may write to inside the browser. There are four in common use. Cookies are small, capped at about 4 KB each, and are sent to the server with every request, which is why they carry sessions. localStorage holds strings, survives a browser restart, and is usually capped near 5 MB per origin. sessionStorage behaves the same way but is wiped when the tab closes. IndexedDB is the large one — an asynchronous key-value database that can hold objects, files and blobs, typically tens or hundreds of megabytes depending on free disk. All four are scoped by origin, meaning scheme plus host plus port, and none of them travel to another visitor.
Why It Matters
Generated apps lean on this constantly, and the misunderstanding is expensive. A habit tracker that saves to localStorage looks like a working product until the owner opens it on their phone and finds it empty — the data never left the laptop. Storage is also not durable in the way a server is. Private-browsing windows discard it on close, browsers evict it under disk pressure, and in Safari script-written storage on a site the user has not engaged with can be cleared after seven days. Treat it as a convenience cache. Anything you would be upset to lose belongs somewhere else, with an export button as the escape hatch.
How It Works
Each API is reached from JavaScript on the page: localStorage.setItem and getItem for strings, the indexedDB object for structured data, document.cookie for cookies. The browser files the data under the page's origin, so a page at demo.99helpers.site cannot read anything written by another subdomain, and the same-origin policy is what enforces that. Reads and writes to localStorage and sessionStorage are synchronous and block the main thread, so a large JSON blob written on every keystroke will make the interface stutter. IndexedDB is promise-shaped and does not block. When a quota is exceeded the write throws a QuotaExceededError rather than silently truncating, so wrap it.
Real-World Example
A designer publishes a client feedback board as one HTML file at studio-notes.99helpers.site through 99helpers. Comments are kept in localStorage, so each reviewer sees only their own notes and the designer sees none of them. The fix is not more storage — it is a Download JSON button on the page plus an emailed file, or posting to a real API. After that change the board becomes a drafting tool rather than a pretend inbox, and nobody is surprised.
Common Mistakes
- ✕Expecting storage to sync between devices or visitors — every browser profile holds its own separate copy
- ✕Putting tokens or personal data in localStorage — any script running on the page, including an injected one, can read it
- ✕Ignoring the quota until it bites — a few hundred base64 images will pass 5 MB and the next write will throw
Related Terms
localStorage
A browser API that stores string key-value pairs on the visitor's device, scoped to one origin and kept until something clears it. Around 5 MB is available, and the data never leaves that one browser.
No-Backend App
An application that runs entirely in the visitor's browser, with no server process of its own. Everything it does — layout, logic, data — happens in downloaded files, so it can be served as plain static files.
Single-File Web App
A single-file web app is a complete, working application contained in one HTML document, with the styles and the JavaScript written inside the same file. Open it in a browser and it runs — there is nothing to install and nothing to build.
Same-Origin Policy
The browser rule that keeps code loaded from one origin from reading data belonging to another. It is the foundation the rest of web security is built on.
Static Hosting
Static hosting is a service that stores a folder of finished web files and serves them over HTTP, without running any application code of yours. You upload the folder; the host answers requests for the files in it.
Put a file online in seconds
Drop in a document, an image, a page or a whole static website and share the link — free, with no build step and no server to set up.
Host a file free →