# Drive

> Folders and files on the attachments module: access granted to users, teams or roles and inherited down the tree, enforced by storage policies too; moves and renames with a name-conflict policy; revisions through versions, a bin through trash, starred and recent items through share-links' user state, and folder share links.

- Category: Content & files
- Module: `drive`
- Modes: `managed`, `custom`
- Docs: https://bettersupabase.com/docs/blocks/drive
- Page: https://bettersupabase.com/blocks/drive

## Install

```bash
npx better-supabase add drive
```

The command also installs `updated-at`, `memberships`, `permissions`, `attachments`, `drive-files`.

## Configure

Add the block to `better-supabase.config.ts`:

```ts
import { defineConfig } from "better-supabase/config";

export default defineConfig({
  blocks: {
    // Required by drive; add installs them too.
    "updated-at": {},
    memberships: {},
    permissions: {},
    attachments: {},
    "drive-files": {},
    // Modes: "managed", "custom". The default is "managed".
    drive: { mode: "managed" },
  },
});
```

## Client

The block has no React entry yet. Its server-side TypeScript is in `better-supabase/blocks/drive`.

## Events

- `drive_node.created`
- `drive_node.download_blocked_changed`
- `drive_node.hold_placed`
- `drive_node.hold_released`
- `drive_node.locked`
- `drive_node.moved`
- `drive_node.ownership_transferred`
- `drive_node.renamed`
- `drive_node.shared`
- `drive_node.unlocked`
- `drive_node.unshared`

## Related blocks

Requires: [memberships](https://bettersupabase.com/blocks/memberships.md), [permissions](https://bettersupabase.com/blocks/permissions.md), [drive-files](https://bettersupabase.com/blocks/drive-files.md)

Works with: [outbox](https://bettersupabase.com/blocks/outbox.md), [audit](https://bettersupabase.com/blocks/audit.md), [attachments](https://bettersupabase.com/blocks/attachments.md), [versions](https://bettersupabase.com/blocks/versions.md), [trash](https://bettersupabase.com/blocks/trash.md), [teams](https://bettersupabase.com/blocks/teams.md), [share-links](https://bettersupabase.com/blocks/share-links.md), [settings](https://bettersupabase.com/blocks/settings.md), [guests](https://bettersupabase.com/blocks/guests.md), [imports](https://bettersupabase.com/blocks/imports.md), [data-lifecycle](https://bettersupabase.com/blocks/data-lifecycle.md), [access-requests](https://bettersupabase.com/blocks/access-requests.md)

## Recipes

- [Grants editor](https://bettersupabase.com/recipes/grants-editor.md): The grants on a drive item, inherited ones included, with a picker to share it with a member or team at a role.
- [File request upload](https://bettersupabase.com/recipes/file-request-upload.md): The public page of a file request link, where anyone with the link sends a file into a folder, with the link's password when it has one.
- [Document register](https://bettersupabase.com/recipes/document-register.md): The organization's controlled documents in a data grid with their number, status, effective version and next review date, flagged when the review is due.
- [Drive explorer](https://bettersupabase.com/recipes/drive-explorer.md): Folders and files with upload, rename, move and a breadcrumb trail, each file with its labels and the approval of its current version.
