⚙
tRPC3mo ago
4 replies

How do I add a Websocket server to a normal tRPC HTTP server for realtime events?

I have a project that contains the following:
- Express API using TRPC
- CapacitorJS mobile app using SolidJS
- PWA app using SolidJS

The PWA has a QR code that displays on a TV in a physical building. The mobile app can scan this QR code and log the user into the system. I wanted to use a websocket implementation so that the PWA knows when the user is authenticated after the QR code scan. If it's possible, I would like the websocket connection to live inside the API project, but I'm not sure if that is doable. My infrastructure is already set up for one API server, it would be great to somehow handle all the requests with one server.

Is this possible? And can you point me to any documentation about how to set that up?

Thanks!
Was this page helpful?