WebSocket Adapters
MoroJS v1.4.0 introduces pluggable WebSocket adapters. Choose Socket.IO for features, native WebSockets for performance, or disable WebSockets entirely for HTTP-only apps.
WebSocket Adapter Configuration
Choose Your WebSocket Adapter
typescript
Universal WebSocket Usage
typescript
Advanced WebSocket Features
WebSocket Event Handling
typescript
Authentication & Middleware
typescript
WebSocket Adapter Comparison
| Adapter | Bundle Size | Performance | Features | Use Case |
|---|---|---|---|---|
| Socket.IO | ~244KB | Good | Rich (rooms, namespaces) | Feature-rich apps |
| Native WS | ~8KB | Excellent | Lightweight | Performance-focused |
| None | 0KB | N/A | HTTP only | REST APIs |
Installation Guide
Socket.IO Projects
npm install socket.io
# Auto-detected
Native WebSocket
npm install ws @types/ws
# Lightweight option
HTTP-Only
No additional deps
# Just disable WS