> ## 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.

# OPFS

> Keep workspace files in browser storage across page reloads.

Browser

OPFS mounts a folder of the browser's Origin Private File System. Its files
stay scoped to the page's origin and survive page reloads.

## Connect

> [tab] TypeScript
>
> ```typescript theme={null}
> import { MountMode, OPFSVFS, Workspace } from '@struktoai/mirage-browser'
>
> const ws = new Workspace(
>   { '/data': new OPFSVFS({ root: 'mirage' }) },
>   { mode: MountMode.WRITE },
> )
> const result = await ws.shell('echo hello > /data/note.txt && cat /data/note.txt')
> console.log(result.stdoutText)
> await ws.close()
> ```

## Layout

```text theme={null}
/data/
  note.txt
  drafts/
    plan.md
```

* `root` is a folder under the origin's OPFS root, so several workspaces can
  keep apart. It defaults to the OPFS root itself.
* Browser only. In Python or Node, use [Disk](https://docs.mirage.strukto.ai/home/setup/disk.md).
* `capacity: '100MB'` caps the bytes the folder holds; see
  [capacity](https://docs.mirage.strukto.ai/home/setup/vfs.md#mount-capacity).

## Sample runs

```bash theme={null}
$ tree /data
/data
|-- drafts
|   `-- plan.md
`-- note.txt

2 directories, 2 files
```

```bash theme={null}
$ cat /data/note.txt
hello
```

Every command that writes works on a `write` mount. The browser sets the
origin's quota and may evict the data under storage pressure; the
[OPFS guide](https://docs.mirage.strukto.ai/typescript/vfs/opfs.md#storage-and-quotas) shows how to check
usage and ask for persistent storage.

## SDK guides

> [card] [TypeScript](https://docs.mirage.strukto.ai/typescript/vfs/opfs.md)
>
> Every config field, the VFS.md and write support.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.