Overview
#Drivers
A driver is an object that implements methods from node:fs/promises.
FsDriver is a subset of node:fs/promises. You can assign node:fs/promises to it without a cast. Any other object with the same shape also works. You do not extend a base class or register an implementation. You only provide the methods.
The package includes three drivers:
import { createMemoryDriver } from "mountx/drivers/memory";
import { createNodeFsDriver } from "mountx/drivers/node-fs";
import { createUnstorageDriver } from "mountx/drivers/unstorage";
const memory = createMemoryDriver(); // a complete filesystem in RAM
const passthrough = createNodeFsDriver("/home/me/data"); // a real directory, rooted
const storage = createUnstorageDriver(store); // any unstorage key–value storeYou might not need to write a driver. If the built-in drivers do not meet your needs, implement the three required methods: stat, readdir, and open.
#Two pages
- Built-in drivers describes memory, node-fs, and unstorage. It lists each option and explains the limits of a key-value store. It also shows how to wrap a driver.
- Writing a driver describes the minimum interface, errors, file handles, and capabilities. It also shows how to develop without mounting.