Chat SDK adds PostgreSQL state adapter
By Steven Van ·
Chat SDK's new adapter lets teams persist subscriptions, locks, and cache state in Postgres instead of adding Redis.
Vercel's Chat SDK now supports PostgreSQL as a state backend, joining Redis and ioredis as production-ready options. Teams that already run Postgres can persist subscriptions, distributed locks, and key-value cache state without adding Redis to their infrastructure.
The new adapter, enabled with createPostgresState()
The new adapter, enabled through createPostgresState() from the @chat-adapter/state-pg package, uses pg (node-postgres) with raw SQL queries and creates its required tables automatically on first connection. It supports TTL-based caching, distributed locking across multiple instances, and namespaced state via a configurable key prefix.
Vercel credited community contributor @bai, whose pull request laid the groundwork for the adapter. Developers can also build their own adapter for other platforms or backends.
