Skip to content

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 should cover the full API surface of the latest Node.js version, though complex changes may lag a little bit. That includes the callback API, the synchronous API, and fs/promises. All with with full type compatibility.

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:

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.