ZenFS backends for DOM APIs. DOM APIs are only available natively in browsers.
Important
Please read the ZenFS core documentation!
WebStorage
: Stores files in aStorage
object, likelocalStorage
andsessionStorage
.IndexedDB
: Stores files into anIndexedDB
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 can require
the package.
If using a browser environment, you can use a <script>
with type=module
(you may need to use import maps)
import { configure, fs } from '@zenfs/core';
import { WebStorage } from '@zenfs/dom';
await configureSingle({ 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);