# Support session banner

> A banner that tells the user a support agent is viewing the app as them, rendered on the server.

- Block: [support-sessions](https://bettersupabase.com/blocks/support-sessions.md)
- Kind: component
- Data: loaded on the server through the block's client
- Page: https://bettersupabase.com/recipes/support-session-banner

## Install the block

```bash
npx better-supabase add support-sessions
```

## Web (Next.js)

Add the shadcn components:

```bash
npx shadcn add alert
```

From `apps/examples/nextjs/src/features/user/components/impersonation-banner.tsx` (https://github.com/ScaleDockHQ/better-supabase/blob/main/apps/examples/nextjs/src/features/user/components/impersonation-banner.tsx):

```tsx
import { LifeBuoyIcon } from "lucide-react";
import { getExtracted } from "next-intl/server";

import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";

import { getSession } from "../user-queries";

/**
 * Shown during a support session (`bs.startSupport`): staff see the app as
 * the user, and the audit log records who acted. Render inside `<Suspense>`.
 */
export async function ImpersonationBanner() {
  const [session, t] = await Promise.all([getSession(), getExtracted("user")]);

  if (session.kind !== "user" || !session.impersonator) {
    return null;
  }

  const { id, reason } = session.impersonator;

  return (
    <Alert variant="destructive" data-testid="impersonation">
      <LifeBuoyIcon />
      <AlertTitle>{t("Support session")}</AlertTitle>
      <AlertDescription>
        {reason
          ? t("Signed in by support ({id}): {reason}", { id, reason })
          : t("Signed in by support ({id}).", { id })}
      </AlertDescription>
    </Alert>
  );
}
```

## Prompt

Paste this into a coding agent to build the recipe in your app.

### Web

```text
Build "Support session banner" in a React web app that uses shadcn/ui components. A banner that tells the user a support agent is viewing the app as them, rendered on the server.

It uses the better-supabase `support-sessions` block (Support sessions). It loads its data on the server through the block's client.

Steps:

1. If the app doesn't have the block yet, add the SQL with `npx better-supabase add support-sessions` and apply the migration.
2. Add the shadcn components the recipe uses: `npx shadcn add alert`.
3. The recipe needs no glue: it calls the block's client on the server.
4. Write the component. Load the data on the server with the block's client, starting from the recipe's snippet (`apps/examples/nextjs/src/features/user/components/impersonation-banner.tsx`). Adapt it to the app's existing components, styling and data loading instead of copying it as is.
5. Check the result against the recipe and the block's docs: it typechecks, it reads the same block data, and it handles the loading and empty states the snippet handles.

Read the full code first:

- Recipe: https://bettersupabase.com/recipes/support-session-banner.md
- Block docs: https://bettersupabase.com/docs/blocks/sql
```
