# Audit log

> Records inserts, updates and deletes with the actor and changed columns for tables you register, plus semantic events through audit_event(), with redaction, an append-only guard, a tenant read policy and per-tenant retention as options.

- Category: Admin & compliance
- Module: `audit`
- Modes: `managed`
- Docs: https://bettersupabase.com/docs/blocks/audit
- Page: https://bettersupabase.com/blocks/audit

## Install

```bash
npx better-supabase add audit
```

## Configure

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

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

export default defineConfig({
  blocks: {
    // Modes: "managed". The default is "managed".
    audit: { mode: "managed" },
  },
});
```

## Client

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

## Related blocks

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

## Recipes

- [Audit log table](https://bettersupabase.com/recipes/audit-log-table.md): The audit trail, newest first, with filters by actor and action and older pages on demand.
