First record

Get started.

Install the package, expose its browser modules, declare a stable application identity, then wait for the singleton before reading or writing.

Before installation

Requirements

DBOPFS is a browser-only ES module. It expects the web platform, not Node.js, a server runtime, or server-side rendering.

RequirementWhy it matters
HTTPS or localhostOPFS is exposed only in a secure browser context.
navigator.storage.getDirectoryOpens the origin-private filesystem root.
ES modulesThe runtime uses imports, top-level await, private fields, and import.meta.url.
Window and Worker APIsThe singleton lives on window; a co-located worker supplies the synchronous-access fallback.
Compression and image APIsRequired only for PNG backup and restore, not ordinary CRUD.

Browser support is capability-based. Test the actual browsers you support. The playground reports each required feature independently.

Step one

Choose npm or the GitHub release.

Both sources contain the same verified dbopfs@1.0.0 package layout.

Install from npm

Use the registry when npm already manages your application's dependencies.

Terminal
npm install dbopfs@1.0.0

Open dbopfs@1.0.0 on npm

Download from GitHub

Use the release tarball when you want plain self-hosted browser files without adding npm to the application.

Download dbopfs-1.0.0.tgz

macOS, Linux, Git Bash, or WSL
curl -fL https://github.com/TheWizardNexus/DBOPFS/releases/download/v1.0.0/dbopfs-1.0.0.tgz -o dbopfs-1.0.0.tgz
mkdir -p vendor/dbopfs
tar -xzf dbopfs-1.0.0.tgz -C vendor/dbopfs --strip-components=1
PowerShell
Invoke-WebRequest 'https://github.com/TheWizardNexus/DBOPFS/releases/download/v1.0.0/dbopfs-1.0.0.tgz' -OutFile 'dbopfs-1.0.0.tgz'
New-Item -ItemType Directory -Force 'vendor/dbopfs' | Out-Null
tar -xzf 'dbopfs-1.0.0.tgz' -C 'vendor/dbopfs' --strip-components=1

Run either command set from the web-project root. It removes the archive's outer package/ directory while preserving the complete DBOPFS package beneath vendor/dbopfs/.

Release notes, checksums, and evidence

Verified release. The npm package and GitHub asset are the same tarball. Test, coverage, checksum, and clean-install evidence are linked from the status page.

Step two

Declare one stable application ID.

Add the declaration before importing DBOPFS. IDs must begin with a lowercase letter, contain only lowercase letters, digits, and single hyphen-separated segments, and be no longer than 64 characters.

HTML
<meta name="arcane-app-id" content="my-app">

That declaration maps browser data to:

OPFS path
apps/my-app/

Arcane host behavior: when the native Arcane.app.current() binding exists, its application ID is authoritative. A mismatch with the document declaration fails before storage opens.

Step three

Expose the package root to the browser.

The package contains browser files, but your web server still decides their public URL. Expose the complete package root at a stable URL such as /vendor/dbopfs/. This preserves the adjacent worker and the package's bundled runtime dependency.

Browser module
import '/vendor/dbopfs/arcane/modules/DBOPFS.js';

Whether the files came from npm or the GitHub release, the public directory must keep this shape:

Public files
/vendor/dbopfs/
├── arcane/modules/
│   ├── AppDataScope.js
│   ├── DBOPFS.js
│   └── DBOPFSWorker.js
└── node_modules/strong-type/
    └── index.js

Do not flatten the package. DBOPFSWorker.js must remain beside DBOPFS.js, and the bundled node_modules/strong-type path must remain below the same package root.

Step four

Wait for the singleton.

Importing the module creates window.dbopfs and starts initialization. Awaiting its persistent readiness promise avoids an event-listener race.

JavaScript
import '/vendor/dbopfs/arcane/modules/DBOPFS.js';

await window.dbopfs.readyPromise;

console.log(window.dbopfs.applicationId);
console.log(window.dbopfs.storagePath);

If event-based orchestration fits your application better, guard the event with the persistent ready flag:

Race-safe event pattern
function begin(){
    if(!window.dbopfs?.ready){
        return;
    }

    // Initialize the application once.
}

window.addEventListener('dbopfs-ready',begin,{once:true});
begin();

Step five

Write and read JSON.

Use a .json filename when you want get() to parse stored JSON back into an object.

JavaScript
const db=window.dbopfs;

await db.set(
    'users',
    'alex.json',
    {
        name:'Alex',
        role:'admin'
    }
);

const user=await db.get('users','alex.json');
console.log(user.role); // "admin"

Record created: the value now lives at apps/my-app/users/alex.json inside this origin's private filesystem.

Next, learn the data formats and batch operations in Guides, or inspect every signature in the API reference.

Common first-run failures

Troubleshooting

SymptomCheck
APP_DATA_SCOPE_REQUIREDAdd the application-ID metadata before the module import.
APP_DATA_SCOPE_INVALIDUse the canonical lowercase, hyphen-separated ID format.
APP_DATA_SCOPE_MISMATCHMake the document declaration match the native or explicit application identity.
APP_DATA_STORAGE_UNAVAILABLEUse HTTPS or localhost and a browser exposing navigator.storage.getDirectory.
Worker request is 404Keep DBOPFSWorker.js beside the imported DBOPFS.js file.
Object comes back as textUse a filename ending in .json; parsing is extension-driven.
Module dependency is 404Verify the installed package includes its bundled strong-type path and that the server exposes it.