Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.mirage.strukto.ai/llms.txt

Use this file to discover all available pages before exploring further.

OPFSResource mounts the Origin Private File System as a Mirage resource. Files persist across page reloads but stay scoped to the current origin.
Browser only. There is no OPFS in Node; for local persistence in Node, use Disk.

Install

pnpm add @struktoai/mirage-browser

Config

import { MountMode, OPFSResource, Workspace } from '@struktoai/mirage-browser'

const opfs = new OPFSResource({ root: 'mirage' })

const ws = new Workspace({ '/data': opfs }, { mode: MountMode.WRITE })
await ws.execute('echo persistent | tee /data/note.txt')
FieldDefaultNotes
root''Subdirectory under the OPFS root. Useful to namespace multiple workspaces.

Mount mode

read, write, exec.

Storage and quotas

The browser sets per-origin quotas (typically a fraction of free disk, single-digit GB on most setups). Hitting it raises QuotaExceededError.
const { quota, usage } = await navigator.storage.estimate()
console.log(`${usage} / ${quota} bytes`)
For long-lived workspaces, request persistent storage early so the browser doesn’t evict your data under storage pressure:
await navigator.storage.persist()
See TypeScript Limitations: Browser for the full set of browser constraints.