
Why Upstash Realtime?
- โฐ Setup takes 60 seconds
- ๐งจ Clean APIs & first-class TypeScript support
- โก Extremely fast, zero dependencies, 1.9kB gzipped
- ๐ป Deploy anywhere: Vercel, Netlify, etc.
- ๐ 100% type-safe using zod v4 or zod mini
- ๐ Automatic connection management w/ message delivery guarantee
- ๐ Built-in middleware and helpers - batteries included
- ๐ถ HTTP-based: Redis streams & server-sent events
Quickstart
Get Upstash Realtime running in your Next.js app in under 60 seconds.1. Installation
2. Configure Upstash Redis
Upstash Realtime is powered by Redis. Grab your credentials from the Upstash Console.
.env
lib/redis.ts
3. Define Event Schema
Define the structure of realtime events in your app:lib/realtime.ts
4. Create Realtime Route Handler
Create your realtime endpoint under/api/realtime/route.ts
:
Itโs important that your route matches this path exactly:
/api/realtime/route.ts
app/api/realtime/route.ts
5. Emit Events
From any server component or API route:app/api/notify/route.ts
6. Subscribe to Events
In your client components:app/components/notifications.tsx
Thatโs it! Your app is now listening for realtime events with full type safety. ๐