Skip to main content
Use devbox.fs to transfer files between the local machine and a Devbox, read and write bytes, and manage remote files and directories.
Filesystem operations start a stopped Devbox automatically. Relative remote paths are passed unchanged to the Devbox’s SFTP or command session. Use absolute paths when the location must be unambiguous. The SDK caches the connection and SFTP channel for reuse.

fs.upload()

Upload one local file to the Devbox. This method does not upload directories.

Example

API reference

Arguments and options

string
required
A path on the machine running the SDK. Relative paths resolve from that process’s current working directory.
string
required
The destination file path in the Devbox.
TransferOptions
Transfer and operation controls.

fs.download()

Download one remote file to the local filesystem. This method does not download directories.

Example

API reference

Arguments and options

string
required
The source file in the Devbox.
string
required
A local destination path. Relative paths resolve from the SDK process’s current working directory.
TransferOptions
The same onProgress, signal, and timeoutMs fields as upload().

fs.copy()

Copy a file or directory within the Devbox. The operation invokes remote cp and rejects when it exits unsuccessfully.

Example

API reference

Arguments and options

string
required
The remote source path.
string
required
The remote destination path.
CopyOptions

fs.readFile()

Read an entire remote file into memory as raw bytes. The SDK does not decode its contents.

Example

API reference

Arguments and options

string
required
The remote file to read.
OperationOptions
Optional signal and timeoutMs operation controls.

Return value

A Uint8Array containing the file’s unmodified bytes.

fs.writeFile()

Write a string or raw bytes to a remote file. The file is created or truncated. Strings are written as UTF-8.

Example

API reference

Arguments and options

string
required
The remote file to create or replace.
string | Uint8Array
required
UTF-8 text or bytes to write.
WriteFileOptions

fs.exists()

Check whether a remote file, directory, or other filesystem object exists.

Example

API reference

Arguments and options

string
required
The remote path to check.
OperationOptions
Optional signal and timeoutMs operation controls.

Return value

false only when the SFTP server reports that the path does not exist. Other failures reject the promise.

fs.rename()

Rename or move a file or directory within the Devbox.

Example

API reference

Arguments and options

string
required
The existing remote path.
string
required
The new remote path.
OperationOptions
Optional signal and timeoutMs operation controls.

fs.mkdir()

Create a remote directory, optionally creating each missing parent directory.

Example

API reference

Arguments and options

string
required
The directory to create.
MkdirOptions

fs.remove()

Remove a remote file or directory. Without recursion, directories must be empty.

Example

API reference

Arguments and options

string
required
The remote path to remove.
RemoveOptions

fs.readdir()

List the immediate children of a remote directory. It does not recurse and excludes . and ...

Example

API reference

Arguments and options

string
required
The remote directory to list.
OperationOptions
Optional signal and timeoutMs operation controls.

Return value

Each entry contains its basename and detected type. Symbolic links are reported as "symlink", not as the type of their target.

Errors and cancellation

All methods reject with the abort signal’s reason, or an AbortError, when cancelled. A finite, non-negative timeoutMs covers activation, connection, and the requested operation. Expiration rejects with DevboxTimeoutError. Invalid timeout values reject with RangeError; SFTP, transport, permission, and missing-path failures otherwise surface as their underlying errors. copy() and recursive remove() reject with Error when the remote command fails. See Handle errors and timeouts for shared error handling guidance.
Last modified on August 26, 2026