Introduction
Framework-agnostic realtime primitives powered by Redis Streams.
forrealtime gives you typed, framework-agnostic server-sent events backed by Redis Streams. The API stays close to @upstash/realtime, but swaps the Redis layer for adapters so you can use ioredis, Bun.redis, or your own client.
Why forrealtime?
- Framework-agnostic SSE handler — accepts a standard
Request, works in Next.js, Hono, TanStack Start, and any runtime that speaksRequest/Response - Typed events from a nested Zod schema — define your event shape once on the server, infer types on the client with no duplication
- Redis Streams for history replay — clients reconnect and replay missed events automatically using the last acknowledged stream ID
- Adapter-based Redis integration — no hard Upstash dependency; bring ioredis, Bun.redis, or write your own adapter
- Small React and Svelte client APIs —
RealtimeProvider,provideRealtime,createRealtime,useRealtime
How it works
- You define a nested Zod schema that describes your event types
Realtimeowns the schema, Redis adapter, and channel APIhandle({ realtime })turns that into an SSE endpoint that accepts a standardRequestRealtimeProvider(React) orprovideRealtime()(Svelte) opens one sharedEventSourcefor the active channels in your appcreateRealtime<typeof realtime>()gives you a fully typeduseRealtime()hook
Packages
| Import path | Contents |
|---|---|
forrealtime | Realtime, handle, MiddlewareContext, HandleOptions, InferRealtimeEvents |
forrealtime/client | RealtimeProvider, createRealtime, useRealtime |
forrealtime/client/svelte | provideRealtime, getRealtimeContext, createRealtime, useRealtime |
forrealtime/adapters/ioredis | createIORedisAdapter |
forrealtime/adapters/bun | createBunRedisAdapter |