Is There Documentation for the Cloudflare Computer `dofs` Package? A Complete Guide

Yes, the @cloudflare/dofs package is fully documented inside the Cloudflare Computer repository with a comprehensive README, dedicated docs, and extensive inline code examples.

The dofs package (Durable-Object File System) provides a SQLite-backed virtual filesystem for Cloudflare Durable Objects. According to the Cloudflare Computer source code, all documentation lives alongside the implementation in packages/dofs/, ensuring every API change is immediately reflected in the docs.

Where to Find @cloudflare/dofs Documentation

Primary Documentation Files

The documentation is organized across four main locations:

The README in packages/dofs/README.md serves as the main entry point, describing the three logical layers that dofs exports: the Database wrapper, filesystem primitives, and the SQLiteWorkspaceProvider adapter.

Core Architecture of @cloudflare/dofs

The package implements three distinct layers, each with dedicated documentation:

1. Database Layer

The Database class wraps a Durable Object's SQLite storage. It includes initializeSchema, a helper that creates the VFS tables required for file operations.

2. Filesystem Primitives Layer

Complete set of async filesystem operations implemented directly against the Database:

  • mkdir, rm, readdir, stat, chmod
  • writeFile, readFile
  • find, ls, grep
  • symlink, readlink
  • gc, watch

Each primitive lives in its own source file under src/fs/. For example, writeFile is implemented in src/fs/writeFile.ts.

3. Provider Layer

SQLiteWorkspaceProvider adapts the primitives to a Node-style filesystem interface compatible with @platformatic/vfs. This includes fd tables, synchronous read/write, and watch capabilities. The computerd daemon uses this provider to expose a FUSE mount.

How to Use @cloudflare/dofs: Code Examples

Initialize a Durable Object Database

import { Database, initializeSchema } from "@cloudflare/dofs";

export class WorkspaceDO extends DurableObject {
  private readonly db: Database;

  constructor(ctx: DurableObjectState, env: Env) {
    super(ctx, env);
    this.db = new Database(ctx.storage);
    // Initialise the VFS tables (vfs_nodes, vfs_blobs, …)
    initializeSchema(this.db, Date.now);
  }
}

This pattern appears in the README at lines 24-35 of packages/dofs/README.md.

Write a File Using Primitives

import { writeFile } from "@cloudflare/dofs/src/fs/writeFile";
import { Database } from "@cloudflare/dofs";

async function createHello(db: Database) {
  const path = "/hello.txt";
  const data = new TextEncoder().encode("Hello Cloudflare!");
  await writeFile(db, path, data);
}

The implementation in src/fs/writeFile.ts handles blob storage, path normalization, and parent directory creation.

Mount the Provider for Node-Style Access

import { SQLiteWorkspaceProvider } from "@cloudflare/dofs";
import { Database } from "@cloudflare/dofs";

const db = new Database(/* Durable Object storage */);
const provider = new SQLiteWorkspaceProvider(db);

// Read a file synchronously
const contents = provider.readFileSync("/hello.txt", "utf8");
console.log(contents);

SQLiteWorkspaceProvider is the main export used by external consumers. The computerd daemon mounts this via FUSE to expose Durable Object storage as a local filesystem.

Apply Sync Protocol Changes

import { applyChanges } from "@cloudflare/dofs/src/sync/apply";

async function pushLocalChanges(db: Database) {
  // `changes` would normally be produced by the client side
  await applyChanges(db, changes);
}

Sync primitives like applyChanges, fetchChanges, and pushObjects live in src/sync/ and power the bidirectional synchronization between local and remote state.

Key Source Files for Deep Documentation

Path Description
packages/dofs/package.json NPM manifest with version, dependencies, export map
packages/dofs/src/index.ts Public entry point; re-exports Database, SQLiteWorkspaceProvider, sync helpers
packages/dofs/src/schema/core.ts Core SQLite schema defining vfs_nodes, vfs_blobs, and related tables
packages/dofs/src/fs/writeFile.ts writeFile primitive implementation
packages/dofs/src/fs/readFile.ts writeFile primitive implementation
packages/dofs/src/fs/stat.ts stat metadata retrieval
packages/dofs/src/sync/apply.ts Sync-protocol apply logic
packages/dofs/src/testing.ts SQLiteTestStorage — in-memory SQLite for unit tests

Each source file includes JSDoc comments and is backed by corresponding .test.ts files that serve as executable documentation.

Relationship to Other Packages

The dofs package sits at the center of the Cloudflare Computer stack:

  • @cloudflare/computer-rpc consumes the sync primitives (applyChanges, fetchChanges) for remote procedure calls
  • @platformatic/vfs defines the interface that SQLiteWorkspaceProvider implements
  • computerd (the local daemon) mounts the provider via FUSE

Repository-wide documentation in docs/10_project_layout.md explains this placement and dependency graph.

Summary

  • Yes, @cloudflare/dofs is thoroughly documented via README, dedicated docs, and inline source comments
  • The README (packages/dofs/README.md) provides architectural overview and quick-start code
  • Filesystem primitives are documented per-function in src/fs/*.ts with corresponding tests
  • Sync protocol primitives are documented in src/sync/*.ts and docs/02_sync_protocol.md
  • SQLiteWorkspaceProvider bridges dofs to Node-style filesystem consumers like computerd

Frequently Asked Questions

Where is the official @cloudflare/dofs documentation hosted?

The primary documentation lives in the Cloudflare Computer repository at packages/dofs/README.md. There is no separate documentation site — all reference material is maintained alongside the source code to ensure accuracy.

What does dofs stand for?

dofs is short for Durable-Object File System. It provides SQLite-backed file storage and operations for Cloudflare Durable Objects, with sync capabilities for local-remote reconciliation.

Can I use @cloudflare/dofs outside of Cloudflare Workers?

The Database class requires a Durable Object Storage interface. However, the package exports SQLiteTestStorage from src/testing.ts for local development and testing. Production use requires a Durable Object environment or compatible storage adapter.

How does the sync protocol work in @cloudflare/dofs?

The sync protocol uses changeset-based reconciliation. Client and server exchange change records via fetchChanges and applyChanges. The pushObjects helper handles bulk object transfer. These primitives are consumed by @cloudflare/computer-rpc to implement real-time workspace synchronization.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →