Web APIs
Browser and network APIs every web app relies on.
About Web APIs
Every web browser has its own set of storage APIs. Websites use them to remember a logged-in user, keep a shopping cart, save a draft, or work offline. Choosing the wrong one leads to lost data, security problems or slow pages.
These guides cover each browser storage option in turn: cookies, localStorage, sessionStorage, IndexedDB, and the newer Origin Private File System, which lets a full SQLite database run in the browser. Each guide explains what the API is for, its limits, and the mistakes developers make most often.
A quick rule of thumb: use a cookie when the server needs the value on every request, such as a login session. Use localStorage for small settings that should survive a restart, sessionStorage for data that belongs to one tab, and IndexedDB when you need to store many records or larger, structured data.
You can practise most of them for real in the Web Storage and IndexedDB playgrounds, which run your commands against the browser's actual APIs.
Start here
- 1HTTP Cookies
How cookies work, and the security flags every login cookie needs.
- 2localStorage
The simplest browser storage, and when it is the wrong choice.
- 3IndexedDB
The browser's real database, for larger and structured data.
localStorage
Persistent, synchronous key-value storage built into every browser.
sessionStorage
The exact same API as localStorage — scoped to one tab, gone the moment that tab closes.
HTTP Cookies
The original client-side storage — small, automatically sent with every request, and still how a stateless protocol remembers you.
IndexedDB
The browser's built-in asynchronous, transactional database — for when localStorage's limits become a real problem.
OPFS & WASM-SQLite
The browser's native file-system access API — and how it makes a real SQLite database possible entirely client-side.