Bringing True SQLite to the Browser with OPFS 🚀
Source: Dev.to

The Problem
For years, we’ve emulated SQL on top of localStorage (5 MB limit) or used IndexedDB (painful API). Modern web apps need more power.
The Solution: web-sqlite-js
web-sqlite-js is a lightweight wrapper around SQLite WASM and the Origin Private File System (OPFS). It gives you a persistent, high‑performance database that lives right in the browser.
Key Features
- True SQLite – Full support for JOINs, Transactions, and Triggers.
- Persistent – Data is saved to the browser’s file system (OPFS).
- Non‑Blocking – Runs in a Web Worker to keep your UI at 60 fps.
- Type‑Safe – First‑class TypeScript support.
Quick Start
npm install web-sqlite-js
import openDB from "web-sqlite-js";
const db = await openDB("my-app.sqlite3");
// Standard SQL
await db.exec("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)");
await db.exec("INSERT INTO users (name) VALUES (?)", ["Alice"]);
// Complex Queries
const users = await db.query("SELECT * FROM users ORDER BY name ASC");
await db.close();
Check it out on GitHub:
Tags: javascript typescript webdev sqlite