The granary’s back room: the real OPFS. What happens when its folder is opened, a write is not yet closed, a second writable writes, a folder with files is…
localStorage keeps only small text, IndexedDB keeps objects. For real files (a SQLite-WASM database, a media cache, an editor’s documents) OPFS gives folders and files of bytes, with no user permission. The rules people miss: a write counts only at close(), createWritable() starts from an empty copy, a folder with files is not removed without recursive, and fast sync access exists only in a Worker.
OPFS is the origin's private folder, and a write counts once it is closed
showOpenFilePicker() and showDirectoryPicker() open the user’s files and always ask for permission. navigator.storage.getDirectory() is another API: a private folder of the origin, with no dialog, never shown to the user.write() was called createWritable() writes to a temporary copy. Only await w.close() puts it in the file; without it (or after abort()) the file stays as it was.createSyncAccessHandle(), whose reads and writes are sync and fast (SQLite-WASM uses it), exists only inside a dedicated Worker. Send the heavy work to a Worker; on the page, use the async createWritable().getDirectory() The origin's root folder, with no permission dialog.getFileHandle with no { create: true } NotFoundError: it only opens a file that is already there.close() file.size is still 0.seek(size) with no keepExistingData The gap fills with NUL bytes.