- Chat rooms
- Emitting events to a specific user
Default Channel
By default, events are sent to thedefault
channel. If we emit an event without specifying a channel like so:
Custom Channels
Emit events to a specific channel:route.ts
page.tsx
Channel Patterns
User-Specific Channels
User-Specific Channels
Send notifications to individual users:
route.ts
page.tsx
Room-Based Channels
Room-Based Channels
Broadcast to all users in a room:
route.ts
Team Workspaces
Team Workspaces
Scope events to team workspaces:
route.ts
Dynamic Channels
Subscribe to multiple channels at the same time:page.tsx
Broadcasting to Multiple Channels
Emit to multiple channels at the same time:route.ts
Channel Security
Combine channels with middleware for secure access control:app/api/realtime/route.ts
Authenticate Realtime Requests
See the middleware documentation for authentication examples