# Support sessions

> Lets platform staff view the app as a user: time-limited, read-only by default, gated by is_platform() and a second admin's approval, recorded in the audit log, with the target's claims built by your access token hook.

- Category: Admin & compliance
- Module: `impersonation`
- Modes: `managed`, `adopt`, `custom`
- Docs: https://bettersupabase.com/docs/blocks/sql
- Page: https://bettersupabase.com/blocks/impersonation

## Install

```bash
npx better-supabase add impersonation
```

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

## Configure

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

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

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

## Client

The block is SQL only: call its functions from your policies, RPCs and the other modules.

## Events

- `support.ended`
- `support.started`

## Related blocks

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

Works with: [invitations](https://bettersupabase.com/blocks/invitations.md), [approvals](https://bettersupabase.com/blocks/approvals.md)

## Recipes

- [Support session banner](https://bettersupabase.com/recipes/support-session-banner.md): A banner that tells the user a support agent is viewing the app as them, rendered on the server.
