Chat core library built in TypeScript with MongoDB persistence and optional Redis pub/sub for cross-instance fanout. Current stable version 0.3.4. It provides a server-side API via initChat() and a lightweight browser client bundle (SocketProvider, useSocket, getSocketManager). Requires mongoose and ioredis as peer dependencies. Ships its own WebSocket transport using the ws library, with server-driven authentication via query parameters. Differentiators: server & client in one package, optional Redis for horizontal scaling, built-in text search, and a Next.js demo app pattern.
npm install wexa-chatNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Initializes chat with MongoDB, no WebSocket server. Shows required peer mongoose and basic options.
Always pass httpServer only when it is available (e.g., after Next.js server is ready). Use the lazy initialization pattern shown in the README.
Ensure server socket.path (if set) equals client's expected path. Both default to '/ws'.
Use conditional: if (process.env.REDIS_URL) { redis: { url: process.env.REDIS_URL } } else if (process.env.REDIS_HOST) { ... }.Do not rely on cors option; configure CORS at the HTTP server level instead.
Update tsconfig.json: set 'moduleResolution' to 'bundler' or 'node16'. Or use paths: { 'wexa-chat/client': ['./node_modules/wexa-chat/dist/client/index.d.ts'] }.Change to: import { initChat } from 'wexa-chat' (or dynamic import).Do not start a separate HTTP server; pass the existing Next.js HTTP server to initChat(). In Next.js, use the socket warm-up route.