# Chat SDK state

> The Chat SDK StateAdapter in Postgres for better-supabase/chat-sdk: thread subscriptions, token locks, a TTL cache, capped lists and per-thread queues under a key prefix, plus the bot installations per workspace with a credential_ref instead of the token. Service role only.

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

## Install

```bash
npx better-supabase add chat-sdk-state
```

The command also installs `housekeeping`.

## Configure

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

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

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

## Client

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

## Related blocks

Requires: [housekeeping](https://bettersupabase.com/blocks/housekeeping.md)

Works with: [housekeeping](https://bettersupabase.com/blocks/housekeeping.md)
