Skip to content

OpfsWorker

Runs the worker side of the browser SQLite WASM client that stores data in OPFS.

This module opens @effect/wa-sqlite with the OPFS access-handle VFS, then listens on a MessagePort-compatible port for the protocol used by SqliteClient. It sends a ready message, executes SQL messages, imports and exports database bytes, forwards update-hook notifications, and closes when requested. It is meant to run in a dedicated worker or a SharedWorker.

2 exports Added in v4.0.0 Source

Models

OpfsWorkerConfig interface

Added in v4.0.0 Source

Configuration for the SQLite OPFS worker, including the message port used for the client protocol and the OPFS database name to open.

Signature

interface OpfsWorkerConfig {
  readonly dbName: string;
  readonly port: EventTarget & Pick<MessagePort, "postMessage" | "close">;
}

Running

run

Added in v4.0.0 Source

Runs the SQLite OPFS worker loop, opening the configured database, posting a ready message, handling query/import/export/update-hook messages, and closing when a close message is received.

Signature

declare function run(options: OpfsWorkerConfig): Effect<void, SqlError>;