Skip to content
Files SDK
Esc
navigateopen⌘Jpreview
On this page

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 { demoFiles } from "@/lib/demo-files";
    import { TrashBin } from "@/registry/files-sdk/trash-bin/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 = demoFiles;
    
      return <TrashBin files={files} />;
    };
    
    export default Example;
    

    Installation

    npx 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

    PropType
    filesUseFilesResult

    A `useFiles()` instance backed by a gateway with the `softDelete()` plugin.

    TypeUseFilesResult
    onChanged?() => void

    Called after a successful restore or purge.

    Type() => void
    className?string
    Typestring

    Was this page helpful?