Registry / database / angular-web-sqlite

angular-web-sqlite

JSON →
library1.0.34jsnpmunverified

Angular service wrapping @sqlite.org/sqlite-wasm for using SQLite in the browser with OPFS storage. Version 1.0.34, released periodically. Key differentiators: integrates seamlessly with Angular via dependency injection, manages Web Worker communication for SQLite ops, supports batch transactions. Uses Origin Private File System for persistent storage. Requires specific Angular/Common and Ionic peer dependencies and special Angular asset configuration.

npm install angular-web-sqlite
INSTALL
IMPORT
SIG · ANGULAR-WEB-SQLITE
A
angular-web-sqlite
databasejavascriptv1.0.34
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.

WebSqlite
import { WebSqlite } from 'angular-web-sqlite';
const WebSqlite = require('angular-web-sqlite');
ESM-only; TypeScript types included.
WebSqlite as provider
providers: [WebSqlite]
WebSqlite in imports array
Must be added as a provider in Angular module or component.
WebSqlite injection
constructor(private webSqlite: WebSqlite) {}
constructor(private webSqlite: any) {}
Use TypeScript type safety.

Shows initialization and basic CRUD with WebSqlite service.

// app.module.ts import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { WebSqlite } from 'angular-web-sqlite'; import { AppComponent } from './app.component'; @NgModule({ declarations: [AppComponent], imports: [BrowserModule], providers: [WebSqlite], bootstrap: [AppComponent] }) export class AppModule { } // app.component.ts import { Component } from '@angular/core'; import { WebSqlite } from 'angular-web-sqlite'; @Component({ selector: 'app-root', template: '<button (click)="run()">Run SQL</button>' }) export class AppComponent { constructor(private db: WebSqlite) {} async run() { await this.db.init('mydb'); await this.db.executeSql('CREATE TABLE IF NOT EXISTS test (id INTEGER PRIMARY KEY, name TEXT)', []); await this.db.executeSql('INSERT INTO test (name) VALUES (?)', ['Alice']); const result = await this.db.executeSql('SELECT * FROM test', []); console.log(result); } }
Debug
Known issues
gotchaRequires Cross-Origin-Opener-Policy and Cross-Origin-Embedder-Policy headers for SharedArrayBuffer support.
fix
Add headers in angular.json serve options as shown in README.
affects: >=1.0.0
breakingMust copy assets from angular-web-sqlite and @sqlite.org/sqlite-wasm to output directory sqlite-client.
fix
Configure assets in angular.json build options.
affects: >=1.0.0
deprecatedPeer dependency on @ionic/angular may become optional in future versions.
fix
Install @ionic/angular if needed, otherwise ignore.
affects: >=1.0.0
gotchaMethods return Promises; must use await or .then().
fix
Use async/await or .then() when calling methods.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Module not found: Error: Can't resolve '@sqlite.org/sqlite-wasm'
Missing copy of assets from sqlite-wasm package.
fix
Add asset configuration in angular.json build options.
TypeError: Cannot read properties of undefined (reading 'executeSql')
Database not initialized before executing query.
fix
Call await this.webSqlite.init(dbName) before any query.
SecurityError: Failed to construct 'Worker'
Cross-Origin-Opener-Policy and Cross-Origin-Embedder-Policy headers not set.
fix
Add headers in angular.json serve options.
Upgrade
Version history
1.0.34latest on npm
Audit
Dependencies
@angular/commonoptionalPeer dependency; required for Angular common features
@angular/coreoptionalPeer dependency; required for Angular core features
@ionic/angularoptionalPeer dependency; required for Ionic integration
Agent activity
13 hits · last 30 days
node
10
Amazon
1
OpenAI (training)
1
Resources
angular-web-sqlite — npm install angular-web-sqlite · libregistry