Effect VirtualFileSystem

Run Effect programs against an in-memory filesystem without touching the host disk. Use it for isolated tests, build previews, or tools that need reproducible filesystem state.

Start with the memory filesystem

npm install @effect-vfs/memory@latest
npm install "@effect/platform-bun@$(npm view @effect-vfs/memory peerDependencies.effect)"
import * as BunCrypto from "@effect/platform-bun/BunCrypto"
import { MemoryFileSystem } from "@effect-vfs/memory"
import { Effect, FileSystem } from "effect"
 
const program = Effect.gen(function* () {
  const fs = yield* FileSystem.FileSystem
  yield* fs.writeFileString(
    "/settings.json",
    JSON.stringify({ mode: "preview" })
  )
  return yield* fs.readFileString("/settings.json")
})
 
const settings = await Effect.runPromise(
  program.pipe(Effect.provide(MemoryFileSystem.layer), Effect.provide(BunCrypto.layer))
)
 
console.log(settings)

The program continues to use Effect's standard filesystem interface. Only the provided layer changes, so production can use a host filesystem while tests and tools use disposable in-memory state.

Choose a package

  • @effect-vfs/memory adapts the virtual filesystem to Effect's standard FileSystem.FileSystem service. This is the usual starting point.
  • @effect-vfs/core provides byte-preserving paths, explicit callers and permissions, shared volumes, fixtures, quotas, watches, overlays, and portable encoded snapshots.
  • @effect-vfs/persistence stores named checkpoints or backs a live volume with SQLite or an experimental R2 store.
  • @effect-vfs/nfs exports a live volume to NFSv4.1 clients. Local read-only access is a preview; qualified writable access is experimental.

All four packages are ESM-only and declare their supported Effect version as an exact peer dependency.