Skip to content
GitHubXDiscord

Folder

The Folder resource creates and manages directories in the filesystem with automatic parent directory creation and cleanup on deletion.

Create a directory using the ID as the path:

import { Folder } from "alchemy/fs";
const dir = await Folder("uploads");

Create a directory with an explicit path:

import { Folder } from "alchemy/fs";
const logs = await Folder("logs", {
path: "var/log/app",
});

Create nested directories with recursive creation enabled (default):

import { Folder } from "alchemy/fs";
const nested = await Folder("nested", {
path: "path/to/nested/dir",
recursive: true,
});

Control folder deletion behavior:

import { Folder } from "alchemy/fs";
const temp = await Folder("temp", {
path: "temp",
delete: true, // Delete on destroy (default)
clean: true, // Remove contents on delete
});