What is ZenFS?
ZenFS is a cross-platform library that emulates the Node.js filesystem API. It works using a system of backends, which are used by ZenFS to store and retrieve data.
ZenFS v2.9.0 implements every fs API documented for Node.js v27.0.0-alpha.0.1.1, and fully supports Node.js v27.0.0-alpha.0.0.0. That includes the callback API, the synchronous API, and fs/promises, all with full type compatibility. Complex changes in new Node.js releases may lag a little
bit, see Node.js compatibility for the details.
Backends
Section titled “Backends”ZenFS is modular and easily extended. Rather than being tied to one storage mechanism, every filesystem is provided by a backend, and backends are mounted into a single tree. The core includes several:
| Backend | Description |
|---|---|
InMemory |
Stores files in-memory. Cleared when the runtime ends. |
CopyOnWrite |
Combines a readable and a writable file system with copy-on-write. |
Fetch |
Downloads files over HTTP with the fetch API. |
Port |
Interacts with a remote over a MessagePort-like interface, e.g. a worker. |
Passthrough |
Uses an existing node:fs interface with ZenFS. |
SingleBuffer |
Contained within a single buffer. Supports synchronous multi-threaded use with a SharedArrayBuffer. |
Many more are provided as separate packages under @zenfs:
@zenfs/archives:Zip,Iso,Tar@zenfs/cloud:Dropbox,GoogleDrive,S3Bucket@zenfs/dom:WebAccess,IndexedDB,WebStorage,XML@zenfs/emscripten:Emscripten, plus a plugin for Emscripten’s own file system API
You can find all of the packages over on NPM. More backends can be defined by separate libraries, see Writing a backend.
As an added bonus, all ZenFS backends support synchronous operations, and all of the backends included with the core are cross-platform.
- Installation and Quick start to get running.
- Using ZenFS for a more in-depth guide.
- Configuration for everything
configureaccepts. - Architecture if you want to know how it all fits together.