Realtime Features for React: Easier Than You Think
Вставка
- Опубліковано 11 січ 2025
- When I was new to web dev, implementing real-time features into your apps seemed like a nightmare. So many things to keep in mind. How to deploy the web sockets? How to manage scaling? I think this might be one of the most beginner-friendly approaches to implementing real-time features into your own app.
My GitHub: github.com/jos...
The minimal realtime chat code: github.com/jos...
Pusher (not sponsored): pusher.com/cha...
I wish you a lot of fun implementing real-time features into your app! Let me know if you build something cool with it! Cheers
Thanks a lot! I was just looking the docs for pusher and was not understanding much and you've just dropped a video.
Been there, at first they confused me too
bro you just created a conclusion for their bad documents, that's hard to believe, YOU A LIFE SAVER.
Thanks, this video is very helpful to grasp the basic of Pusher
Hope you do well onwards!
Pppppp😊pp
7:25 The real-time functionality
Clearer than the doc or Vercel tutorial, thanks !
Needed this for a clock in system I’m building. Very nice tutorial 🔥.
Excellent Josh, great video as always. ...(ps. prisma format -> makes it so pretty)
Good video, thank you very much for sharing your knowledge. I really hope you keep producing videos with the same intensity.
Best regards, all the best from Brazil 🇧🇷
Cheers man, appreciate you
have you got a repo for reference? Curious how to set up the part where pusher talks to the db to preserve the state
Good call, will update that in the description
@@joshtriedcoding waiting for the update 👍👍
@@asimalqasmi7316 It's available in the description now: github.com/joschan21/minimal-react-realtime
I tried it myself before you sent the repo
It stumbled on useRouter in app page since it wasn't clear in the video until I figured out it was imported from navigation not router.
If you want to see my repo I'll share it here. 😁
"Hello and welcome to this video's content, accurately described by this video's title"
nice video Josh. Just one thing... I wouldn't teach other developers to use a let in a react client component instead of the useState hook. In this particular case it works because you don't have any parent component. But it is really a bad practice and should not be used in a client component to maintain state.
Just curious will it not work if you wrap this let component with a parent component?
@@JB2519 no it wont
amazing bro. It was really something new for me . THnakss for the video
KEEP GOING !!!, you have such GOOOD content
can we use pusher to implement ads campain feature like google ads, I mean showing users data as ad in queue in real time ?
Great tutorial! But what if I have multiple channel I need to listen to? Do I need to create one useEffect per channel or put all listeners in one useEffect?
can react query do the same thing? provide real time updates?
Today, i'm creating a chat in my school'project, and i don't khow how to unsubcribe channel_name inside return callback of UseEffect. Thanks you !
@Josh,
Great video again. Does this also work in NextJS 12?
hi josh,
Can you explain how to use SWR for realtime data. From the info I got on Twitter, it says it doesn't use third party services / web scoket.
i am very interested about that
Have you got your answer ?
Can I use this with Strapi?
Hi. How long have you been learning web dev?
Gonna make a video on that soon :)
Is it complex to setup a internal websocket on NextJS ?! 😢
Due to NextJS being serverless and WS requiring stateful connections, you can't. That's why I found this method so convenient, alternatively NodeJS with socket.io for small scale apps is totally fine too
@@joshtriedcoding Isn’t it that nextjs embed expressjs, and actually have a backend? The prisma calls for example are server side, right ?
@@hn3m3s1s Yes they are server-side. NextJS API routes use NodeJS, however, due to them being serverless, you don't have access to some APIs such as the file system. You can think of it as "every time my NextJS API gets called, I am 'renting' out a few seconds of a server's resources for this route to process the request".
@@joshtriedcoding Wuw, thanks for that! Very clear explanation and I understand now better how next works!
@@joshtriedcodingWhy would you recommend it for small scale apps only? What better alternatives could you name for sth like a Java api + React/Next client?
jump to 7:24
why dint you use useState for the input value?
no need to
I'm not overly familiar with Prisma, but I was under the impression that you needed to set it up to work with a 3rd party DB service like Supabase or Planetscale. If so, which are you using in this project? If not, where is the database located?
Any supported dbs and hosted anywhere.
I love the intros to these videos, very German 😆
thank you josh!
"use server" = prisma not api again 😢
That's really good, but it's paid and limited. The free version is also limited
THANK YOU!! the Pusher docs were so trash.
Thanks 🙏
I think its sponsored
Woow
NOt helpful
Just showing your code