chishiki-adapter-web
v0.2.1
Published
Web StorageAdapter for Chishiki - SQLite via OPFS using sqlocal
Maintainers
Readme
chishiki-adapter-web
Web StorageAdapter for Chishiki — SQLite via OPFS using sqlocal. Any cross-origin-isolated web app gets a local Chishiki LRS without needing the Chrome extension.
Install
npm install chishiki-adapter-web chishikiUsage
import { createChishiki } from 'chishiki';
import { WebAdapter } from 'chishiki-adapter-web';
const chishiki = createChishiki({
storage: new WebAdapter(), // default: 'chishiki.sqlite3'
// storage: new WebAdapter({ filename: 'my-lrs.db' }),
});
await chishiki.initialize();Requirements
Your page must be cross-origin isolated for OPFS access:
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corpExport / Import
import { WebAdapter } from 'chishiki-adapter-web';
const adapter = new WebAdapter();
await adapter.initialize();
// Export database as Uint8Array
const data = await adapter.export();
// Import from Uint8Array (overwrites current database)
await adapter.import(data);License
MIT
