This example showcases the use of httpSubscriptionLink
to facilitate .useSubscription
via Server-sent Events.
Try demo http://sse.trpc.io/
This project includes 2 examples of the subscription pattern:
- Simple example of
whoIsTyping
- A slightly more involved example of
livePosts
- Hooks for both cases (using
trpc.{x}.useSubscription
) can be found in/src/app/channels/[channelId]/hooks.ts
- The
EventEmitter
&whoIsTyping
subscription route can be found in/src/server/routers/channel.ts
- The more complex
post
subscription route can be found in/src/server/routers/post.ts:79