How do tRPC WebSockets work with NextJS

Hey! I've recently stumbled upon this repo: https://github.com/trpc/examples-next-prisma-websockets-starter. I'm a little confused on how it would be able to hold a connection with a serverless environment.
Solution:
it looks like they setup a websocket server there, and host they on "render"
Jump to solution
12 Replies
Solution
Zion
Zion17mo ago
it looks like they setup a websocket server there, and host they on "render"
domi?
domi?OP17mo ago
So the site and websocket server are hosted differently? Or everything is hosten on render?
Zion
Zion17mo ago
pretty sure everything is hosted on render try to deploy that exmaple app yourself on render to see how it works ig
Neto
Neto17mo ago
on the example there are 2 servers running on the same machine
Neto
Neto17mo ago
GitHub
examples-next-prisma-websockets-starter/package.json at main · trpc...
🏓 tRPC Next.js WebSocket Starter. Contribute to trpc/examples-next-prisma-websockets-starter development by creating an account on GitHub.
Neto
Neto17mo ago
in the real world, you are going to use something like pusher, socketi or whatever
Zion
Zion17mo ago
why is it preferable? trpc subscriptions are not production ready or?
Neto
Neto17mo ago
trpc is fine the ws side is the faulty one vercel does not host any ws service vercel run on lambdas, so you wont host there as well in the example is fine to host both of them, but in the real world you wont gonna use the same
Zion
Zion17mo ago
its not possible to host the ws server on render or something and the lambdas / app itself on vercel?
Neto
Neto17mo ago
yep, its a alternative
darthreza
darthreza17mo ago
Question from a beginner, if we are running a linux bare metal server that we have configured to be able to run next.js apps, then it should be fine to use ws, right? The reason not to use ws is not that the ws package is inherently limited, but that some hosting platforms to not allow it. Correct?
OtterSwims996
OtterSwims99612mo ago
Yes i think you're totally fine running something like this on your own linux server
Want results from more Discord servers?
Add your server