ZenFS backends for DOM APIs. DOM APIs are only available natively in browsers.
Important
Please read the ZenFS core documentation!
Storage: Stores files in aStorageobject, likelocalStorageandsessionStorage.IndexedDB: Stores files into anIndexedDBobject database.FileSystemAccess: Store files using the Web File System API.
For more information, see the API documentation.
Note
The examples are written in ESM. If you are using CJS, you can require the package. If running in a browser you can add a script tag to your HTML pointing to the browser.min.js and use ZenFS DOM via the global ZenFS_DOM object.
import { configure, fs } from '@zenfs/core';
import { Storage } from '@zenfs/dom';
await configure({ backend: Storage, 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);