sql-js/sql.js: A javascript library to run SQLite on the web. @GitHub
sql.js is a javascript SQL database. It allows you to create a relational database and query it entirely in the browser. You can try it in this online demo. It uses a virtual database file stored in memory, and thus doesn't persist the changes made to the database. However, it allows you to import any existing sqlite file, and to export the created database as a JavaScript typed array.
sql.js uses emscripten to compile SQLite to webassembly (or to javascript code for compatibility with older browsers). It includes contributed math and string extension functions.
SQLite can run completely inside a web browser. This is made possible by compiling SQLite's original C code into WebAssembly (Wasm), allowing it to execute locally on the client side with near-native performance. Major applications like Notion use this exact architecture to speed up their web apps. [1, 2, 3, 4]
- It lets you load the SQLite library onto a web page using vanilla JavaScript.
- It interacts with modern storage APIs like the Origin Private File System (OPFS) to persist physical database files across sessions.
- Note: To leverage OPFS persistence, your web server must be configured to output strict security headers, specifically and . [1, 7, 8, 9]
- sql.js: A highly popular port that compiles SQLite to JavaScript/Wasm. By default, it operates completely in temporary RAM (in-memory). While your data disappears upon a page refresh, it allows you to easily import an existing database file via an array buffer or export your session data back into a static file.
- wa-sqlite: An alternative wrapper designed for flexible virtual file systems (VFS), allowing developers to map SQLite engines smoothly onto IndexedDB or OPFS backends. [7]
No comments:
Post a Comment