ZenFS backends for DOM APIs. DOM APIs are only available natively in browsers.
[!IMPORTANT] Please read the ZenFS core documentation!
WebStorage
: Stores files in a Storage
object, like localStorage
and sessionStorage
.IndexedDB
: Stores files into an IndexedDB
object database.WebAccess
: Store files using the File System Access API.For more information, see the API documentation.
[!NOTE] The examples are written in ESM.
For CJS, you canrequire
the package.
For a browser environment without support fortype=module
inscript
tags, you can add ascript
tag to your HTML pointing to thebrowser.min.js
and use the globalZenFS_DOM
object.
import { configure, fs } from '@zenfs/core';
import { WebStorage } from '@zenfs/dom';
await configure({ backend: WebStorage, storage: localStorage });
if (!fs.existsSync('/test.txt')) {
fs.writeFileSync('/test.txt', 'This will persist across reloads!');
}
const contents = fs.readFileSync('/test.txt', 'utf-8');
console.log(contents);
Generated using TypeDoc