Registry / database / meadow-connection-sqlite-browser

meadow-connection-sqlite-browser

JSON →
library1.0.2jsnpmunverified

A browser-compatible SQLite connection provider for the Meadow ORM, version 1.0.2. It replaces the native better-sqlite3 addon with sql.js (SQLite compiled to WASM), enabling Meadow to run in web browsers. It provides a better-sqlite3 compatible API wrapper, supporting in-memory databases only. It is maintained as part of the Meadow ecosystem, with updates following the Meadow release cadence. Unlike the standard meadow-connection-sqlite (better-sqlite3), this package works in both browser and Node.js environments without native dependencies.

npm install meadow-connection-sqlite-browser
INSTALL
IMPORT
SIG · MEADOW-CONNECTION-
M
meadow-connection-sqlite-browser
databasejavascriptv1.0.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

MeadowConnectionSQLiteBrowser
const libMeadowConnectionSQLiteBrowser = require('meadow-connection-sqlite-browser');
import MeadowConnectionSQLiteBrowser from 'meadow-connection-sqlite-browser';
Package uses CommonJS; no default ESM export.
connectAsync
const connection = new libMeadowConnectionSQLiteBrowser(); connection.connectAsync(callback);
libMeadowConnectionSQLiteBrowser.connectAsync(callback);
connectAsync is an instance method, not static. You must instantiate the service first.
Fable Service Registration
fable.serviceManager.addServiceType('MeadowSQLiteProvider', libMeadowConnectionSQLiteBrowser);
fable.serviceManager.addServiceType('MeadowConnectionSQLiteBrowser', libMeadowConnectionSQLiteBrowser);
Service type name must match expectations of Meadow; 'MeadowSQLiteProvider' is the standard.

Shows how to register the Meadow SQLite browser connection provider with Fable, connect, and perform basic SQL operations using the better-sqlite3 compatible API.

const libFable = require('fable'); const libMeadowConnectionSQLiteBrowser = require('meadow-connection-sqlite-browser'); let fable = new libFable({ Product: 'MyApp', ProductVersion: '1.0.0' }); // Register and instantiate the service fable.serviceManager.addServiceType('MeadowSQLiteProvider', libMeadowConnectionSQLiteBrowser); let connection = fable.serviceManager.instantiateServiceProvider('MeadowSQLiteProvider'); connection.connectAsync((pError, pDatabase) => { if (pError) { console.error('Connection failed:', pError); return; } // Use the better-sqlite3 compatible wrapper directly connection.db.exec('CREATE TABLE Test (id INTEGER PRIMARY KEY, name TEXT)'); connection.db.prepare('INSERT INTO Test (name) VALUES (:name)').run({ name: 'hello' }); let rows = connection.db.prepare('SELECT * FROM Test').all(); console.log(rows); });
Debug
Known issues
gotchaPackage does not bundle sql.js WASM files. You must manually serve sql-wasm.js and sql-wasm.wasm from node_modules/sql.js/dist/ and load the script in your HTML.
fix
Copy sql-wasm.js and sql-wasm.wasm to your static assets directory and add <script src='./sql-wasm.js'></script> before your bundle.
affects: >=1.0.0
gotchaIn-memory only. Data is lost on page refresh or when the WebAssembly context is destroyed. Not suitable for persistent storage.
fix
Use meadow-connection-sqlite (better-sqlite3) for Node.js persistent storage, or implement export/import mechanisms.
affects: >=1.0.0
deprecatedThe package uses `require('sql.js')` in Node.js, which may not work with strict ESM environments.
fix
Ensure your project uses CommonJS or configure bundler to handle sql.js correctly.
affects: >=1.0.0
gotchaIn browser, sql.js expects a global `initSqlJs` function. If not loaded via script tag, the package will fail with 'initSqlJs is not defined'.
fix
Add a script tag to load sql-wasm.js before your application bundle.
affects: >=1.0.0
Errors
Common errors & fixes
initSqlJs is not defined
sql.js WASM loader not loaded in browser environment.
fix
Add <script src='path/to/sql-wasm.js'></script> before your main script.
require is not defined
Using CommonJS require in an ESM-only environment (e.g., modern browser with ES modules).
fix
Use a bundler like webpack or browserify, or use the browser-compatible build from the package.
cannot find module 'sql.js'
Optional dependency sql.js not installed or bundled incorrectly.
fix
Run `npm install sql.js` and ensure it is in node_modules. For browser bundler, add bundler.ignore('sql.js') and load manually via script tag.
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies
sql.jsrequiredProvides SQLite WASM engine; this package wraps it for Meadow compatibility
Agent activity
7 hits · last 30 days
node
6
Resources
meadow-connection-sqlite-browser — npm install meadow-connection-sqlite-browser · libregistry