The next evolution of SQLite is here! Read Announcement
Modern web applications demand database-level performance directly in the browser. Users expect instant responses, offline capabilities, and seamless experiences regardless of network conditions.
Today, we're launching Turso in the Browser, bringing the full power of SQLite directly to your web applications via WebAssembly.
npm install @tursodatabase/database-wasm
Turso in the Browser represents the next evolution of SQLite. This isn't just SQLite compiled to WebAssembly, it's a complete rewrite focused on performance and browser-native capabilities.
The database NPM package provides an API similar to better-sqlite3
, but all execution methods are asynchronous (async
) due to the way OPFS works in the browser.
You can connect to a database using the dedicated connect
helper or by explicitly creating a Database
instance.
The recommended approach is to use the connect
helper. However, if you can't use it -- for example, when top-level await
isn't available -- you can create a Database
instance synchronously instead.
import { connect, Database } from "@tursodatabase/database-wasm";
// Recommended: use the connect helper
const db = await connect("local.db");
// Alternatively, create a Database instance manually
const db = new Database("local.db");
// and connect later
await db.connect();
console.info(await db.prepare("SELECT ?").run([42]));
You can provide either a local filename or the special :memory:
location, which creates an ephemeral in-memory database that is reset after a page reload.
To explore more details and features — take a look at the examples !
The high-level components of the tursodatabase in the browsers includes the following:
The front-end ecosystem is very diverse — so we added extra ways to consume the library from different environments:
Vite
or Turbopack
as bundler — use dedicated export from the library: @tursodatbase/database-wasm/vite
or @tursodatabase/database-wasm/turbopack
@tursodatabase/database-wasm
and let us know if there are any issues with the package!Turso in the Browser opens up new possibilities for web applications. From offline-first productivity tools to real-time collaborative applications that work regardless of connectivity.
Whether you're building a local-only application or one that occasionally syncs with the cloud, Turso in the Browser provides the foundation for fast, reliable, and scalable web applications.