Drizzle / Postgres
Use the current Drizzle ChatStore schema and shared Postgres client.
createDrizzleChatStore() returns the default self-hosted ChatStoreFactory.
It uses DATABASE_URL unless a connection string is passed explicitly.
import {
createDrizzleChatStore,
getDrizzleDb,
schema,
} from '@mordn/chat-widget/server/drizzle';
DATABASE_URL="postgres://user:password@host:5432/database"
Current schema
The scaffolded drizzle.config.ts points directly to:
'./node_modules/@mordn/chat-widget/dist/server/drizzle/index.js'
Run:
npx drizzle-kit push
This creates chat_conversations and chat_messages. The schema exported from
@mordn/chat-widget/server/drizzle is the same current handler schema.
Handler wiring
export const { GET, POST, DELETE } = createChatHandler({
getUserId: getChatUserId,
model: anthropic('claude-sonnet-4-5'),
store: createDrizzleChatStore(),
});
connectionStringstringDefault:
DATABASE_URLPostgres connection string.
maxnumberDefault:
5Maximum pool connections.
The client disables prepared statements for transaction-mode poolers. Use
getDrizzleDb() for advanced queries against the shared pool.