A NestJS module that integrates the ws WebSocket client library, providing a decorator-based API for WebSocket connections. Version 0.1.3 is the latest stable release, with no recent updates since 2022. It uses ws under the hood and offers synchronous and asynchronous module configuration via forRoot and forRootAsync. Key differentiators: full NestJS DI integration, decorators like @OnOpen and @OnMessage, and support for both Express and Fastify platforms. Currently in maintenance mode.
npm install nestjs-websocketNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to configure WebSocketModule, inject WebSocketClient, and use @OnOpen/@OnMessage decorators in a NestJS service.
Use ws' API for binary data (e.g., Buffer). Avoid assuming browser webSocket behavior.
Consider using built-in @nestjs/websockets or migrate to a more active alternative like '@nestjs/platform-ws'.
Use it as property decorator: @InjectWebSocketProvider() private ws: WebSocketClient;
If upgrading from older versions, change your code to use the injected instance directly.
Run 'npm install nestjs-websocket' and ensure tsconfig.json includes 'node_modules' in types or has 'skipLibCheck: false'.
Add a valid WebSocket URL to the options object, e.g., { url: 'ws://localhost:3000' }.Use property decorator: @InjectWebSocketProvider() private ws: WebSocketClient;