Skip to content

trpc/examples-next-sse-chat

Repository files navigation

tRPC + Server-sent Events (SSE)

This example showcases the use of httpSubscriptionLink to facilitate .useSubscription via Server-sent Events.

Try demo http://sse.trpc.io/

Features

  • 🧙‍♂️ E2E type safety with tRPC
  • ⚡ Full-stack React with Next.js
  • ⚡ Server-Sent-Events / Subscription support
  • ⚡ Database with Drizzle
  • 🔐 Authorization using next-auth

Code

This project includes 2 examples of the subscription pattern:

  1. Simple example of whoIsTyping
  2. A slightly more involved example of livePosts

Setup

git clone [email protected]:trpc/examples-next-sse-chat.git
pnpm i
cp .env.example .env
pnpm dev