Protocols
WebSocket Adapters
Pluggable WebSocket adapters. Choose Socket.IO for features, native WebSockets for performance, or disable WebSockets entirely for HTTP-only apps.
Overview
Different apps need different WebSocket solutions. With MoroJS, you choose the adapter that fits your needs - same API, different backends. Traditional WebSocket setup locks you into one solution. We give you flexibility with a consistent API.
Without Adapters
- Locked into one WebSocket library
- Different APIs for different libraries
- Hard to switch between solutions
- No flexibility for different use cases
With MoroJS
- Choose the adapter that fits your needs
- Same API across all adapters
- Easy to switch between adapters
- Auto-detection for zero config
Universal WebSocket Usage
typescript
Flexible
Choose Socket.IO for features or native WS for performance. Same API.
Automatic
Auto-detection finds the best adapter. Zero configuration needed.
Consistent
Same API across all adapters. Switch between them easily.
How It Works
MoroJS uses a pluggable adapter system for WebSockets. You can choose Socket.IO for feature-rich applications, native WebSocket (ws) for performance, or disable WebSockets entirely for HTTP-only apps. The API remains consistent across all adapters.
WebSocket Adapter Configuration
Choose Your WebSocket Adapter
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 |