Skip to content
pubscout

sqlite3_web

0.9.6, released 2 weeks ago by simonbinder.eu

Async SQLite access on the web via workers with automatic storage detection

WASM-ready
$ flutter pub add sqlite3_web
Source repository

What it does

Provides a Dart API to run SQLite in web workers, handling async communication, feature detection, and storage backend selection. It exposes a WebSqlite class that opens databases, runs queries, and manages locks.

AI-written summary of version 0.9.6, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need SQLite on the web and prefer async worker-based access
  • You want automatic detection of the best persistence API (IndexedDB, OPFS, etc.)
  • You are building a higher-level library that requires a worker‑based SQLite backend

Skip it when

  • You are building a simple web app that can use localStorage or IndexedDB directly
  • You need a pure synchronous API
  • You are targeting non‑web platforms

Strengths

  • Worker‑based async access avoids blocking the UI
  • Automatic detection of available storage backends
  • Built for integration with higher‑level libraries like sqlite_async or drift
  • Supports lock management for transactions

Weaknesses

  • Requires a wasm binary and worker setup
  • Limited to web platform only
  • Setup can be complex for beginners
  • No direct support for non‑web platforms

Setup

Kind
Pure Dart
Effort
Medium
Code generation
No
Direct dependencies
3

Add sqlite3.wasm to your web assets, compile worker with dart compile js, and provide WorkerConnector to WebSqlite.open

```dart
import 'package:sqlite3_web/sqlite3_web.dart';

Future<void> main() async {
  final sqlite = await WebSqlite.open(
    workers: WorkerConnector.defaultWorkers('worker.dart.js'),
    wasmModule: 'sqlite3.wasm',
  );
  final features = await sqlite.runFeatureDetection();
  final conn = await sqlite.connectToRecommended('my_database');
  print(await conn.database.select('select sqlite_version()'));
}
```

Works with

Packages commonly used together with sqlite3_web: ones it builds on, ones built on it, and its own family.