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
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.
- websqlite3_web depends on itLightweight bindings for browser APIs via JS interop
- sqlite3sqlite3_web depends on itLightweight and convenient SQLite bindings for Dart using dart:ffi
- driftSame familyDrift is a reactive library to store relational data in Dart and Flutter applications.
- drift_devSame familyGenerates Dart database code from Drift table definitions as a dev‑dependency.
- drift_flutterSame familyProvides a simple Flutter‑specific helper to open drift databases on all platforms.
- sqlite3_flutter_libsSame familyObsolete package that once bundled native SQLite libraries for Flutter; now contains no code.
- sqlite_asyncBuilt on sqlite3_webHigh-performance asynchronous SQLite interface for Dart and Flutter.
- powersyncBuilt on sqlite3_webPowerSync Dart and Flutter SDK. Sync Postgres, MongoDB, MySQL or SQL Server with SQLite in your app