# Notifications

> In-app notifications sent through a security definer notify(): one event per change, per-recipient read, dismissed and resolved state, per-channel deliveries, subject subscriptions, preferences with a tenant override, and realtime on a private topic.

- Category: Notifications & messaging
- Module: `notifications`
- Modes: `managed`, `custom`
- Docs: https://bettersupabase.com/docs/blocks/notifications
- Page: https://bettersupabase.com/blocks/notifications

## Install

```bash
npx better-supabase add notifications
```

The command also installs `updated-at`.

## Configure

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

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

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

## Client

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

## Events

- `notification.bounced`
- `notification.clicked`
- `notification.complained`
- `notification.created`
- `notification.delayed`
- `notification.delivered`
- `notification.opened`

## Related blocks

Requires: [updated-at](https://bettersupabase.com/blocks/updated-at.md)

Works with: [permissions](https://bettersupabase.com/blocks/permissions.md), [profiles](https://bettersupabase.com/blocks/profiles.md), [memberships](https://bettersupabase.com/blocks/memberships.md), [data-lifecycle](https://bettersupabase.com/blocks/data-lifecycle.md), [consents](https://bettersupabase.com/blocks/consents.md), [housekeeping](https://bettersupabase.com/blocks/housekeeping.md)

## Recipes

- [Notification bell](https://bettersupabase.com/recipes/notification-bell.md): A header button with the unread count, which updates when a notification arrives or is read.
- [Notification list](https://bettersupabase.com/recipes/notification-list.md): The caller's latest notifications with an unread marker, loaded again on every change.
