T3 for a chat app

Although I don't remember the exact video now. I remember Theo saying that the t3 stack would not be optimal for an application that constantly updates it's data. I assumed this meant something like a chat app that relies heavily on web sockets. If I am correct here, could someone help me understand why using t3 app is not optimal for this type of app? Also what should I use instead?
11 Replies
Matvey
Matvey2y ago
i think this is the video you're talking about - https://youtu.be/-R9uHm0G5m4 T3 stack is expected to be deployed on a serverless environment. Serverless isn't designed for long connections, so you can't really use websockets You can still use T3 for a chat app. tRPC has subscriptions, and they are very useful for getting updates. Just deploy it with docker on a VPS
adnanjpg
adnanjpg2y ago
Just deploy it with docker on a VPS wouldn't you be deploying all of your next.js app on your own this way? is there any disadvantages between this approach vs deploying on vercel?
Neto
Neto2y ago
vercel run on lambdas and you (kinda) can't use ws on lambdas
korgko
korgko2y ago
You can take a look at this example that uses soketi for sockets that might help you. https://github.com/pingdotgg/zapdos
GitHub
GitHub - pingdotgg/zapdos
Contribute to pingdotgg/zapdos development by creating an account on GitHub.
javiercervera
javiercervera2y ago
This Vercel article provides some solutions to the issue with websockets https://vercel.com/guides/publish-and-subscribe-to-realtime-data-on-vercel I am planning to use Supabase Realtime to subscribe the frontend/client to Supabase so that changes made to the database can be published back on the client
Vercel Documentation
How to Add Realtime Communication on Vercel Applications
Learn how to integrate realtime communication to your Vercel application using providers like Ably or Supabase.
MadaShindeInai
Hmm, looks like there are 2 ways: drop idea of building chat (build it as http / use 3-rd party embedded solution) or leave Vercel (welcome to the Docker world and getting lots of devops job) Hmm, maybe server-side events can be somehow used for this purposes? thinkies
zsrobinson
zsrobinson2y ago
Server sent events have the same problems that web sockets do in regards to deploying on serverless I believe Nextjs doesn't force you into deploying on serverless, so you could always just put it on some random VPS if you don't expect to be the next whatsapp
MadaShindeInai
Hmm, and what about building separate ws server in NodeJS, hosting it somewhere, and connecting to it from NextJS client (from component)? I really do not want to leave Vercel, as deploying create-t3-turbo somewhere is a f..ken hell
zsrobinson
zsrobinson2y ago
Yeah that seems like it could be a good way to go about it, that's pretty much what all those other web socket providers are doing
MadaShindeInai
Interesting thing is how to make that ws connection protected, as it is external app.
adnanjpg
adnanjpg2y ago
supabase may be the best solution. I added real time post update to my simple app using postgres_changes (https://supabase.com/docs/guides/realtime/extensions/postgres-changes) https://github.com/adnanjpg/baykus/blob/main/src/hooks/useRealtimePostUpdates.ts for chat, the Broadcast method would probably be better https://supabase.com/docs/guides/realtime/extensions/broadcast
Postgres Changes | Supabase Docs
Getting started with Realtime's Postgres Changes feature
GitHub
baykus/useRealtimePostUpdates.ts at main · adnanjpg/baykus
Contribute to adnanjpg/baykus development by creating an account on GitHub.
Broadcast | Supabase Docs
Getting started with Realtime's Broadcast feature
Want results from more Discord servers?
Add your server