Trash Bin
A recycle bin that lists, restores and permanently purges soft-deleted files — driven by useFiles and the softDelete plugin.
Lists soft-deleted objects and restores or permanently purges them. Backed by the softDelete() plugin, so it needs a gateway whose Files instance is wrapped with it and whose authorize allow-lists the trashed, restoreTrashed and purge operations. Purges confirm first — they’re the only way the bytes actually leave storage.
"use client";
import { demoFiles } from "@/lib/demo-files";
import { TrashBin } from "@/registry/files-sdk/trash-bin/trash-bin";
const Example = () => {
// The docs preview has no gateway: `demoFiles` is a static stand-in for
// `useFiles()` whose `trashed()` returns a canned list and whose restore and
// purge only log. In an app, pass `useFiles()` against a gateway whose
// `Files` instance uses the `softDelete()` plugin.
const files = demoFiles;
return <TrashBin files={files} />;
};
export default Example;
Installation
npx shadcn@latest add https://files-sdk.dev/r/trash-bin.jsonUsage
import { useFiles } from "files-sdk/react";
import { TrashBin } from "@/components/files-sdk/trash-bin";
export function Trash() {
const files = useFiles({ endpoint: "/api/files" });
return <TrashBin files={files} />;
}
The gateway must expose the plugin verbs:
createFilesRouter({
files: createFiles({ adapter, plugins: [softDelete()] }),
operations: ["trashed", "restoreTrashed", "purge"],
});
Under a multi-tenant authorize keyPrefix, the listing and “empty trash” are scoped to the caller’s own keys — purging never reaches another tenant’s trash.
Props
filesUseFilesResult
A `useFiles()` instance backed by a gateway with the `softDelete()` plugin.
UseFilesResultonChanged?() => void
Called after a successful restore or purge.
() => voidclassName?string
string