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
13 Replies
Solution
Zion
Zionโ€ข2y ago
it looks like they setup a websocket server there, and host they on "render"
domi?
domi?OPโ€ข2y ago
So the site and websocket server are hosted differently? Or everything is hosten on render?
Zion
Zionโ€ข2y ago
pretty sure everything is hosted on render try to deploy that exmaple app yourself on render to see how it works ig
Neto
Netoโ€ข2y ago
on the example there are 2 servers running on the same machine
Neto
Netoโ€ข2y 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
Netoโ€ข2y ago
in the real world, you are going to use something like pusher, socketi or whatever
Zion
Zionโ€ข2y ago
why is it preferable? trpc subscriptions are not production ready or?
Neto
Netoโ€ข2y 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
Zionโ€ข2y ago
its not possible to host the ws server on render or something and the lambdas / app itself on vercel?
Neto
Netoโ€ข2y ago
yep, its a alternative
darthreza
darthrezaโ€ข2y 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
OtterSwims996โ€ข14mo ago
Yes i think you're totally fine running something like this on your own linux server
!wild_duck ๐Ÿฆ†๐Ÿค๐Ÿšถ
i am encounting an issue with TRPC and Websockets idk but the documentaion code is not working with me i have tried many way searching in this for days now without any reselution i can rely on, ๐Ÿ™‚ i have set everything up works fine but can not send file chunk from the client to the backend with this trpc any help ??

Did you find this page helpful?