Drizzle / Postgres

createDrizzleChatStore() returns the default self-hosted ChatStoreFactory. It uses DATABASE_URL unless a connection string is passed explicitly.

code
import {
  createDrizzleChatStore,
  getDrizzleDb,
  schema,
} from '@mordn/chat-widget/server/drizzle';
code
DATABASE_URL="postgres://user:password@host:5432/database"

Current schema

The scaffolded drizzle.config.ts points directly to:

code
'./node_modules/@mordn/chat-widget/dist/server/drizzle/index.js'

Run:

code
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.

Warning

@mordn/chat-widget/schema is the legacy pre-handler schema entry and is not an alias for the current server/drizzle schema. Do not use it for a new handler installation.

Handler wiring

code
export const { GET, POST, DELETE } = createChatHandler({
  getUserId: getChatUserId,
  model: anthropic('claude-sonnet-4-5'),
  store: createDrizzleChatStore(),
});
connectionStringstringdefault: DATABASE_URL
Postgres connection string.
maxnumberdefault: 5
Maximum pool connections.

The client disables prepared statements for transaction-mode poolers. Use getDrizzleDb() for advanced queries against the shared pool.