Chat SDK adds PostgreSQL state adapter

1 min read

Chat SDK now supports PostgreSQL as a state backend, joining Redis and ioredis as a production-ready option with the new PostgreSQL adapter.

Teams that already run PostgreSQL can persist subscriptions, distributed locks, and key-value cache state without adding Redis to their infrastructure.

Try the PostgreSQL state adapter today:

import { Chat } from "chat";
import { createPostgresState } from "@chat-adapter/state-pg";
const bot = new Chat({
userName: "mybot",
adapters: {
/* ... */
},
state: createPostgresState(),
});

The adapter uses pg (node-postgres) with raw SQL queries and automatically creates the required tables on first connect. It supports TTL-based caching, distributed locking across multiple instances, and namespaced state via a configurable key prefix.

Read the documentation to get started or browse the adapters directory.

Special thanks to @bai, whose community contribution in PR #154 laid the groundwork for this adapter.