# Comments

> Comments on any record as its conversation on the messaging core: whoever reads the record reads them, with replies, mentions and mention groups, anchors, files, edits with history, pins, resolved threads and read markers. The author and the mentioned follow the record and its followers hear of new comments (with notifications), and a comment becomes a work item (with tasks).

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

## Install

```bash
npx better-supabase add comments
```

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

## Configure

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

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

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

## Client

The React hooks are the registry item `@better-supabase/use-comments` (`npx shadcn add @better-supabase/use-comments`). They return data and actions and render no UI. Source: https://github.com/ScaleDockHQ/better-supabase/blob/main/packages/registry/items/hooks/use-comments.ts

## Related blocks

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

Works with: [notifications](https://bettersupabase.com/blocks/notifications.md), [tasks](https://bettersupabase.com/blocks/tasks.md), [reactions](https://bettersupabase.com/blocks/reactions.md), [attachments](https://bettersupabase.com/blocks/attachments.md), [subjects](https://bettersupabase.com/blocks/subjects.md)

## Recipes

- [Comment thread](https://bettersupabase.com/recipes/comment-thread.md): A record's comments with their authors and a form to add one, kept current after each write.
- [My work](https://bettersupabase.com/recipes/my-work.md): What waits on the caller across the installed blocks, from `getMyWork`: assigned work, approvals, due reminders, mentions and SLA warnings, each linked to its record.
- [Subject timeline](https://bettersupabase.com/recipes/subject-timeline.md): One record's comments, files and versions merged newest first, from `bsb.record(...).timeline`, skipping the bindings the caller can't read.
- [Record page](https://bettersupabase.com/recipes/record-page.md): One row as a page: its fields, the rows that reference it, and comments and tags once the table is a subject.
