BrowserFS backends for DOM APIs. DOM APIs are only available natively in browsers.
Please read the BrowserFS documentation!
HTTPRequest: Downloads files on-demand from a webserver usingfetch.Storage: Stores files in aStorageobject, likelocalStorageandseesionStorage.IndexedDB: Stores files into anIndexedDBobject database.WorkerFS: Lets you mount the BrowserFS file system configured in the main thread in a WebWorker, or the other way around!
For more information, see the API documentation.
npm install @browserfs/fs-dom- Make sure you have Node and NPM installed. You must have Node v18 or newer.
- Install dependencies with
npm install - Build using
npm run build - You can find the built code in
dist.
🛈 The examples are written in ESM. If you are using CJS, you can
requirethe package. If running in a borwser you can add a script tag to your HTML pointing to thebrowser.min.jsand use BrowserFS DOM via the globalBrowserFS_DOMobject.
You can use DOM backends, though you must register them if you plan on using configure:
import { configure, fs } from '@browserfs/core';
import { Storage } '@browserfs/fs-dom';
// you can also add a callback as the last parameter instead of using promises
await configure({ fs: 'Storage' });
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);Run unit tests with npm test.