When #
DuckDB-Wasm# was launched in 2021, databases could not be persisted: everything lived in the Wasm heap and vanished when the tab closed.
Keeping data meant serializing tables to Parquet, storing the bytes in IndexedDB, and re-registering them on the next page load. This was doable, but had to be handled at the application layer and was not offered out of the box by DuckDB-#
Wasm#.
Modern browsers now ship the Origin Private File System (OPFS), a per-origin, sandboxed file system with random-access reads and writes. DuckDB-Wasm can use it as a storage backend.
This post by
@carlo_piovesan and
@GeertjanW shows you how: