Framework Integrations
socket-serve works seamlessly with all major backend frameworks. Choose your framework below for detailed setup instructions.Supported Frameworks
Next.js
Serverless functions with App Router
Express
Traditional Node.js server
Hono
Edge runtime & Cloudflare Workers
Fastify
High-performance Node.js framework
Quick Comparison
| Framework | Best For | Runtime | Deployment |
|---|---|---|---|
| Next.js | React apps, Vercel | Node.js / Edge | Vercel, Netlify |
| Express | Traditional apps | Node.js | Any Node host |
| Hono | Edge computing | Edge / Node.js | Cloudflare Workers, Vercel |
| Fastify | High performance | Node.js | Any Node host, Docker |
Common Patterns
SSE Connection Handler
All frameworks need to handle Server-Sent Events (SSE) connections:POST Message Handler
Framework-Specific Examples
Next.js (App Router)
Express
Hono (Edge)
Fastify
Universal Client Code
The client works the same regardless of backend framework:Authentication Patterns
JWT Authentication
- Next.js
- Express
- Hono
- Fastify
CORS Configuration
- Next.js
- Express
- Hono
- Fastify
Rate Limiting
- Next.js
- Express
- Hono
- Fastify
Deployment Targets
Vercel
- Next.js (recommended)
- Hono
- Express (with adapters)
Cloudflare Workers
- Hono (recommended)
- Next.js Pages Functions (limited)
- Express and Fastify not supported
Traditional Hosts (AWS, DigitalOcean, etc.)
- Express
- Fastify
- Next.js standalone
- Hono
Docker
- Express
- Fastify
- Next.js standalone
- Hono
Performance Comparison
Based on benchmarks with 1000 concurrent connections:| Framework | Req/sec | Latency (p95) | Memory |
|---|---|---|---|
| Hono (Edge) | 15,000 | 12ms | 80MB |
| Fastify | 12,000 | 15ms | 120MB |
| Express | 8,000 | 25ms | 150MB |
| Next.js | 7,000 | 30ms | 180MB |
Choosing the Right Framework
Use Next.js if you’re:
- Building a React application
- Deploying to Vercel
- Using SSR or SSG features
- Want integrated routing and API routes
Use Express if you’re:
- Working with an existing Express codebase
- Need broad middleware ecosystem support
- Prefer traditional Node.js patterns
- Running on traditional servers
Use Hono if you’re:
- Deploying to edge runtimes
- Need lightweight and fast performance
- Targeting Cloudflare Workers
- Want minimal dependencies
Use Fastify if you’re:
- Building high-performance APIs
- Need built-in schema validation
- Prefer modern Node.js patterns
- Creating microservices
Migration Guide
From Socket.IO
socket-serve provides a similar API to Socket.IO:- All operations are async/await
- Uses Redis for state (required)
- No WebSocket requirement
- HTTP-based transport