{"id":48929917,"url":"https://github.com/haroonwaves/sqlite-wasm-easy","last_synced_at":"2026-04-17T08:33:38.240Z","repository":{"id":334951701,"uuid":"1141240794","full_name":"haroonwaves/sqlite-wasm-easy","owner":"haroonwaves","description":"A simple, zero-config wrapper around @sqlite.org/sqlite-wasm","archived":false,"fork":false,"pushed_at":"2026-03-05T03:12:12.000Z","size":119,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-12T21:12:13.884Z","etag":null,"topics":["browser-storage","database","localstorage","sqlite-wasm","sqlite3"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/haroonwaves.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-24T14:10:01.000Z","updated_at":"2026-03-05T03:12:16.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/haroonwaves/sqlite-wasm-easy","commit_stats":null,"previous_names":["haroonwaves/sqlite-wasm-easy"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/haroonwaves/sqlite-wasm-easy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haroonwaves%2Fsqlite-wasm-easy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haroonwaves%2Fsqlite-wasm-easy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haroonwaves%2Fsqlite-wasm-easy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haroonwaves%2Fsqlite-wasm-easy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/haroonwaves","download_url":"https://codeload.github.com/haroonwaves/sqlite-wasm-easy/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haroonwaves%2Fsqlite-wasm-easy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31922026,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-16T18:22:33.417Z","status":"online","status_checked_at":"2026-04-17T02:00:06.879Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["browser-storage","database","localstorage","sqlite-wasm","sqlite3"],"created_at":"2026-04-17T08:33:37.543Z","updated_at":"2026-04-17T08:33:38.234Z","avatar_url":"https://github.com/haroonwaves.png","language":"TypeScript","readme":"# @haroonwaves/sqlite-wasm-easy\n\nA simple, zero-config wrapper around `@sqlite.org/sqlite-wasm` that runs SQLite in a Web Worker\nautomatically.\n\n## Why?\n\nThe official [@sqlite.org/sqlite-wasm](https://github.com/sqlite/sqlite-wasm) is powerful but\nlow-level. Setting it up with Web Workers, handling OPFS (Origin Private File System), and managing\nmessage passing can be complex.\n\n**sqlite-wasm-easy** solves this by:\n\n- 🚀 **Zero-Config**: Works out of the box.\n- 🧵 **Worker-First**: Runs in a Web Worker by default to keep your main thread unblocked.\n- 💾 **OPFS Support**: Easy persistence configuration.\n- 🛡️ **Type-Safe**: Written in TypeScript with full type definitions.\n\n## Installation\n\n```bash\nnpm install @haroonwaves/sqlite-wasm-easy\n```\n\n## TypeScript Usage (Recommended)\n\nFor the best experience, define your schema interface and use the `table()` helper. This gives you\nstrong typing and a cleaner API.\n\n```typescript\nimport { SQLiteWASM } from '@haroonwaves/sqlite-wasm-easy';\n\n// 1. Define your schema\ninterface DatabaseSchema {\n\tusers: {\n\t\tid: number;\n\t\tname: string;\n\t\temail: string;\n\t\tcreated_at: number;\n\t};\n\tposts: {\n\t\tid: number;\n\t\ttitle: string;\n\t\tcontent: string;\n\t};\n}\n\n// 2. Initialize with Schema\nconst db = new SQLiteWASM\u003cDatabaseSchema\u003e({ filename: 'my-app.db' });\n\nawait db.ready();\n\n// 3. Use the table() API\n// The '$' symbol is automatically replaced by the table name ('users')\n\n// Create Table\nawait db.table('users').exec(`\n  CREATE TABLE IF NOT EXISTS $ (\n    id INTEGER PRIMARY KEY AUTOINCREMENT,\n    name TEXT NOT NULL,\n    email TEXT\n  )\n`);\n\n// Insert (Fully typed params are not enforced yet, but return types are)\nawait db\n\t.table('users')\n\t.run('INSERT INTO $ (name, email) VALUES (?, ?)', ['Alice', 'alice@dev.com']);\n\n// Query (Returns User[])\nconst allUsers = await db.table('users').query('SELECT * FROM $');\n```\n\n## Configuration\n\nThe `SQLiteWASM` constructor accepts a configuration object to tailor the database to your needs.\n\n```typescript\nconst db = new SQLiteWASM({\n\tfilename: 'my-database.db', // Required: Database file name\n});\n```\n\n## Available APIs\n\nUse these APIs to interact with the database.\n\n### `exec(sql, params?)`\n\nExecute SQL statements (e.g., `CREATE`, `DELETE`) without returning rows.\n\n### `query\u003cT\u003e(sql, params?)`\n\nExecute a `SELECT` query and return an array of results.\n\n### `run(sql, params?)`\n\nExecute a statement (e.g., `INSERT`, `UPDATE`) and return `{ lastInsertRowId, changes }`.\n\n### `transaction(callback)`\n\nRun multiple operations in a transaction. Automatically handles `BEGIN`, `COMMIT`, and `ROLLBACK`.\n\n```typescript\nawait db.transaction(async (tx) =\u003e {\n\tawait tx.run('INSERT INTO log (action) VALUES (?)', ['update_start']);\n\tawait tx.run('UPDATE users SET name = ? WHERE id = ?', ['Bob', 1]);\n});\n```\n\n### `export() / import()`\n\nExport the entire database as a `Uint8Array` or import one from memory.\n\n## Type Reference\n\nKey interfaces for better TypeScript integration.\n\n### `SQLiteWASMConfig`\n\n```typescript\ninterface SQLiteWASMConfig {\n\tfilename: string; // Required: Database file name\n\tvfs?: {\n\t\ttype?: 'opfs' | 'opfs-sahpool' | 'memory'; // Default: 'opfs'\n\t\tpoolConfig?: {\n\t\t\t// Only used when type is 'opfs-sahpool'\n\t\t\tinitialCapacity?: number; // Default: 3\n\t\t\tclearOnInit?: boolean; // Default: false\n\t\t\tname?: string; // Default: 'sqlite-wasm-pool'\n\t\t};\n\t};\n\tpragma?: {\n\t\tjournal_mode?: 'DELETE' | 'TRUNCATE' | 'PERSIST' | 'MEMORY' | 'WAL' | 'OFF'; // Default: 'WAL'\n\t\tsynchronous?: 'OFF' | 'NORMAL' | 'FULL' | 'EXTRA'; // Default: 'NORMAL'\n\t\ttemp_store?: 'DEFAULT' | 'FILE' | 'MEMORY'; // Default: 'MEMORY'\n\t\tforeign_keys?: 'ON' | 'OFF'; // Default: undefined (not set)\n\t};\n\tlogging?: {\n\t\tfilterSqlTrace?: boolean; // Default: true\n\t\tprint?: (message: string) =\u003e void; // Default: console.log\n\t\tprintErr?: (message: string) =\u003e void; // Default: console.error\n\t};\n}\n```\n\n\u003e **Note:** The `opfs` VFS requires your server to set COOP/COEP headers\n\u003e (`Cross-Origin-Opener-Policy: same-origin` and `Cross-Origin-Embedder-Policy: require-corp`). If\n\u003e these headers are not available, use `opfs-sahpool` instead, which works without them.\n\n### `RunResult`\n\nReturned by `run()` and `table().run()`.\n\n```typescript\ninterface RunResult {\n\tlastInsertRowId?: number; // ID of the last inserted row\n\tchanges?: number; // Number of rows affected\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharoonwaves%2Fsqlite-wasm-easy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fharoonwaves%2Fsqlite-wasm-easy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharoonwaves%2Fsqlite-wasm-easy/lists"}