sqflite-common-ffi-web-setup

Configures sqflite SQLite databases for Flutter web and Dart web apps using WebAssembly.

3.0k|555|Updated May 22, 2017
One-click install
npx skills add https://github.com/tekartik/sqflite --skill sqflite-common-ffi-web-setup-tekartik
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: sqflite-common-ffi-web-setup
Source: https://github.com/tekartik/sqflite/tree/main/packages_web/sqflite_common_ffi_web/skills/sqflite-common-ffi-web-setup
Command: npx skills add https://github.com/tekartik/sqflite --skill sqflite-common-ffi-web-setup-tekartik

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Running SQLite in the browser requires WebAssembly binaries, a worker script, and IndexedDB persistence wiring that are easy to misconfigure. This Skill guides the complete setup of package:sqflite_common_ffi_web so sqflite databases work on Flutter web and Dart web. ## Core Features & Use Cases - Binary setup: Runs dart run sqflite_common_ffi_web:setup to generate web/sqlite3.wasm and web/sqflite_sw.js, with force rebuild and custom output options. - Factory selection: Chooses between databaseFactoryFfiWeb (shared worker, cross-tab safe), databaseFactoryFfiWebNoWebWorker (main thread), and the basic worker variant. - Cross-platform integration: Sets the global databaseFactory behind kIsWeb so existing sqflite code works on web, mobile, and desktop. - Use Case: A Flutter app using sqflite on Android and iOS needs web support; set databaseFactory = databaseFactoryFfiWeb when kIsWeb and the same openDatabase calls work in the browser with IndexedDB persistence. ## Quick Start Add sqflite_common_ffi_web to my Flutter project, run its setup command, and configure the database factory so my existing sqflite code also works on the web.

Frequently Asked Questions about sqflite-common-ffi-web-setup

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I use sqflite in a Flutter web app?▼

Add sqflite_common_ffi_web, run dart run sqflite_common_ffi_web:setup to generate web/sqlite3.wasm and web/sqflite_sw.js, then set databaseFactory = databaseFactoryFfiWeb when kIsWeb is true. Your existing openDatabase calls then work in the browser.

How to run SQLite in the browser with Dart?▼

Use package:sqflite_common_ffi_web, which compiles sqlite3 to WebAssembly and persists databases in IndexedDB. Open a database with databaseFactoryFfiWeb.openDatabase('my_db.db') after running the package setup command to install the wasm and worker files.

Why does sqflite web fail with 'failure to find the worker javascript file'?▼

This error means web/sqflite_sw.js is missing because dart run sqflite_common_ffi_web:setup was not run or the files were not deployed. Re-run setup after adding or upgrading the package and ensure both files are served from the site root.

Does sqflite_common_ffi_web work with dart2wasm builds?▼

Yes, dart2wasm (flutter build web --wasm) is supported since version 1.2.0 with sqflite_common 2.5.13 or later. With older versions, deleteDatabase and databaseExists silently fail when compiled with dart2wasm.

Why does my web database disappear between debugging sessions?▼

IndexedDB storage is scoped per origin including the port, so localhost:8080 and localhost:8081 are separate stores. Always debug on the same port to keep accessing the same database.

What are the limitations of sqflite on the web?▼

It is experimental and slower than native, singleInstance: false throws for persistent databases, and the basic Worker fallback on Android Chrome is not cross-tab safe. There is no OPFS backend and no path_provider support; database names are virtual file system keys.