Overview
#Drivers
A driver is an object with node:fs/promises methods. That is the entire interface.
FsDriver is deliberately a subset of node:fs/promises — so much so that node:fs/promises itself is assignable to it with no cast, and so is anything already shaped like it. There is nothing to extend, register or implement beyond writing the methods.
Three drivers ship with the package, so you may not have to write one at all:
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 storeAnd when none of them is what you have, three methods — stat, readdir, open — are enough to write your own.
#Two pages
- Built-in drivers — memory, node-fs and unstorage: what each is good for, every option, the trade-offs a key–value store brings, and how to wrap one.
- Writing a driver — the minimum interface, errors, file handles, capabilities, and building the whole thing without mounting anything.