Skip to content

@venturekit-pro/chat

@venturekit-pro/chat provides chat primitives — 1-1, group, and channel rooms with participant roles, message history, edit/soft-delete, read receipts, typing indicators, and presence. Storage is pluggable via the ChatStore interface, and there is no baked-in transport — pair it with WebSockets, SSE, or any pub/sub you already run.

Terminal window
npm install @venturekit-pro/chat@dev
import { createChatManager, type ChatStore } from '@venturekit-pro/chat';
const store: ChatStore = /* your storage adapter */;
const chat = createChatManager(store);
// Direct (1-1) room
const room = await chat.createDirectRoom('user-1', 'user-2');
// Send + read
await chat.sendMessage({ roomId: room.id, senderId: 'user-1', content: 'Hello!' });
const messages = await chat.getMessages(room.id, { limit: 50 });
await chat.markRead(room.id, 'user-2', messages[0].id);
const group = await chat.createRoom({
type: 'group', // 'direct' | 'group' | 'channel'
name: 'Project Alpha',
participants: [
{ userId: 'user-1', role: 'owner' }, // 'owner' | 'admin' | 'member' | 'guest'
{ userId: 'user-2', role: 'member' },
],
});
await chat.addParticipant(group.id, 'user-3', 'member');
await chat.removeParticipant(group.id, 'user-2');
MethodDescription
createRoom(options)Create a room (direct rooms require exactly 2 participants)
createDirectRoom(userA, userB)Shortcut for a 1-1 room
getRoom(roomId) / listRooms(userId)Read rooms
addParticipant(roomId, userId, role?) / removeParticipant(roomId, userId)Manage membership (not allowed on direct rooms)
sendMessage(options)Send a message (type defaults to 'text')
getMessages(roomId, { limit?, before? })Paginated message history
editMessage(messageId, senderId, content)Edit (sender only)
deleteMessage(messageId, userId)Soft-delete (sender or room admin/owner)
markRead(roomId, userId, messageId)Mark read up to a message
getUnreadCounts(userId)Per-room unread counts
deleteRoom(roomId)Delete a room

The package is transport- and storage-agnostic. Implement the ChatStore interface (12 methods covering rooms, messages, and read receipts) against DynamoDB, Postgres, Redis, or an in-memory adapter for tests.

import type { ChatStore } from '@venturekit-pro/chat';

RoomType, ParticipantRole, ChatMessageType, ChatRoom, Participant, ChatMessage, TypingEvent, PresenceStatus, UserPresence, UnreadCount, ChatStore, CreateRoomOptions, SendMessageOptions.

  • @venturekit/core — required