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.

Loading…
    "use client";import { useFiles } from "files-sdk/react";import { TrashBin } from "@/components/files-sdk/trash-bin";const Example = () => {  // A demo gateway whose `Files` instance is wrapped with the `softDelete()`  // plugin and seeded with a few soft-deleted files.  const files = useFiles({ endpoint: "/api/files-trash" });  return <TrashBin files={files} />;};export default Example;

    Installation

    npx shadcn@latest add https://files-sdk.dev/r/trash-bin.json
    pnpm dlx shadcn@latest add https://files-sdk.dev/r/trash-bin.json
    bunx --bun shadcn@latest add https://files-sdk.dev/r/trash-bin.json

    Usage

    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

    Prop

    Type

    On this page