# Share links

> Hashed share links, view counts and per-user state. The token is returned once. Resolving a link hashes the token the caller presents, so a stored plaintext token keeps working after it is hashed. A link can take a password, checked with bcrypt and rate-limited per link, and turn off downloads.

- Category: Collaboration
- Module: `share-links`
- Modes: `managed`, `custom`
- Docs: https://bettersupabase.com/docs/blocks/share-links
- Page: https://bettersupabase.com/blocks/share-links

## Install

```bash
npx better-supabase add share-links
```

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

## Configure

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

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

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

## Client

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

## Events

- `share_link.created`
- `share_link.revoked`
- `subject.viewed`

## Related blocks

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

Works with: [outbox](https://bettersupabase.com/blocks/outbox.md), [versions](https://bettersupabase.com/blocks/versions.md), [subjects](https://bettersupabase.com/blocks/subjects.md), [rate-limit](https://bettersupabase.com/blocks/rate-limit.md)

## Recipes

- [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.
- [Share link dialog](https://bettersupabase.com/recipes/share-link-dialog.md): A dialog that creates an expiring link to a record and revokes it.
