Upstash Documentation

Channels

1 min read

Channels allow you to scope events to specific people or rooms. For example:

  • Chat rooms
  • Emitting events to a specific user

Default Channel#

By default, events are sent to the default channel. If we emit an event without specifying a channel like so:

it can automatically be read using the default channel:


Custom Channels#

Emit events to a specific channel:

route.ts

Subscribe to one or more channels:

page.tsx

Channel Patterns#

User-Specific Channels

Send notifications to individual users:

route.ts
page.tsx
Room-Based Channels

Broadcast to all users in a room:

route.ts
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