How to use WebSockets with React and Node

  Рет қаралды 17,901

Ably Realtime

Ably Realtime

Күн бұрын

In this WebSocket tutorial, Alex Booker (@bookercodes) from Ably teaches you how to implement realtime updates in your React applications. Here, we use React on the frontend and Node on the back to build a live cursors feature from scratch, but the fundamental WebSocket lessons can be applied to any manner of realtime application.
WebSockets are a bidirectional full-duplex communication protocol used to enable realtime updates such as chat, multiplayer collaboration, notifications, and other live updates in your React applications.
Compared to the other humdrum WebSocket videos out there, in this video, you will learn WebSockets by *doing*.
Follow along as we build something awesome. In doing so, you'll learn WebSockets well enough at a fundamental level to apply them in any project now, or in the future.
TIMESTAMPS ⏰
00:00 Introduction
01:12 WebSockets vs HTTP
03:08 3 things you need to know about WebSockets
05:52 What you'll build
07:41 WebSockets with Node
39:28 WebSockets with React
01:08:47 Conclusion
LINKS MENTIONED 🔗
- Check out Ably hubs.ly/Q028HG7S0
- Check out Spaces by Ably hubs.ly/Q028HG5Q0
- WebSocket handbook: hubs.ly/Q028HFK90
- Ably's diagram-based guide to WebSockets: hubs.ly/Q028HG5n0
- Tutorial source code on GitHub hubs.ly/Q028HHqV0
- How to scale WebSockets to millions of connections • How to scale WebSocket...
ABOUT ABLY 👋
Ably is an enterprise-grade pub/sub messaging platform. We make it easy to efficiently design, quickly ship, and seamlessly scale critical realtime functionality delivered directly to end-users. Every day, we deliver billions of realtime messages to millions of users for thousands of companies.
ABLY ON SOCIAL
Twitter / ablyrealtime
LinkedIn / ably-realtime

Пікірлер: 44
@robcataus
@robcataus Ай бұрын
I’m the author of react-use-websocket, and stumbled on this video. Your kind words made my weekend!❤
@AblyRealtime
@AblyRealtime Ай бұрын
Great to hear from you, and thanks for commenting ❤️
@bookercodes
@bookercodes Ай бұрын
Haha, no way, amazing to see you here! Great work on react-use-websocket!
@gabrielvaz8083
@gabrielvaz8083 Ай бұрын
This is HIGH-level content, 10/10 quality, 10/10 content, I'm shocked by the low viewership, I wish you all the best on your journey as a content creator
@Cyandog
@Cyandog 6 ай бұрын
This video is just so good. EXTREMELY high quality content. Thank you very much! This is the type of video that not only adds value to other people but make them remember you and your business. Will recommend this to anyone looking to learn about WS! Wish you the utmost success!
@AblyRealtime
@AblyRealtime 6 ай бұрын
Thanks for the kind words! Glad to hear you like the video.
@Cyandog
@Cyandog 5 ай бұрын
​@@AblyRealtimei got a few questions if possible. Could you make just one users object and put the connections there? Also, the on message handler needs to be inside the on connection one?
@AblyRealtime
@AblyRealtime 5 ай бұрын
​@@Cyandog You can structure the code that way if you prefer! There's no implication on functionality or performance, so it really comes down to your preference and what you find most logical to follow. Regarding the message handler - yep, that's right! - Alex
@luciano_romano1
@luciano_romano1 4 ай бұрын
You the man!
@beingmyself3706
@beingmyself3706 Ай бұрын
Extremely useful, easy to understand, perfect ^)
@54peace
@54peace 4 ай бұрын
Such a quality content there! 👍 Websocket has been overwhelming for me as a socket io user, and this expalins a very decent way love it. I really hope to see more educational contents like this from this channel and alst but not least Ably looks really interesting to give a try too!
@StudioShop
@StudioShop Ай бұрын
Thanks for a great tutorial. Appreciate it.
@AblyRealtime
@AblyRealtime Ай бұрын
😁
@JohnMcclaned
@JohnMcclaned 6 ай бұрын
Thanks for the interesting video, would be great to also see how to use Ably in my projects too.
@AblyRealtime
@AblyRealtime 6 ай бұрын
Thanks for the kind words John, we're working on more videos so stay tuned 😎
@nxone9903
@nxone9903 2 ай бұрын
Underrated channel.
@AblyRealtime
@AblyRealtime 2 ай бұрын
🙌
@user-he5uv6ij7e
@user-he5uv6ij7e 5 ай бұрын
Many thanks ! Would also love to see how to implement Ably websockets in a Next.JS app :)
@AblyRealtime
@AblyRealtime 4 ай бұрын
Thanks for letting us know, a great suggestion!
@hlibtumakov4367
@hlibtumakov4367 6 ай бұрын
Since Node v.15.6.0 you don't need to install `uuid` from npm. There is a Node's native module called 'node:crypto' which exports 'randomUUID` (UUID v4) function.
@AblyRealtime
@AblyRealtime 6 ай бұрын
Thanks, will feed this back to the team.
@wushupro
@wushupro 5 ай бұрын
Awesome tutorial! I think I’m missing something. You’ve added useref to stop it rerendering but why does it re render so much in the first place? I thought react components only re render if state or props change?
@AblyRealtime
@AblyRealtime 5 ай бұрын
React useWebSocket forces a render when lastJsonMessage is updated. In other words, the component renders every time a new WebSocket message is received - Alex
@AbdurRahim-eu3zr
@AbdurRahim-eu3zr 6 ай бұрын
Using light theme is like bringing a flashlight to a laser show - let's keep it dark and mysterious, shall we?
@AblyRealtime
@AblyRealtime 6 ай бұрын
Thanks for your feedback, we will keep it in mind for future videos.
@keyonlewis7574
@keyonlewis7574 6 ай бұрын
​@@AblyRealtimeyes that would be nice
@justiceessiel6123
@justiceessiel6123 6 ай бұрын
Are the hackthon projects repos available want to do sth close to uber so if there is a blog on that as well or a video that be created with react or react native that would be great
@AblyRealtime
@AblyRealtime 6 ай бұрын
Hello, you can find the hackathon project gallery at ably.devpost.com/project-gallery but the repos may not be public.
@GriffynGould
@GriffynGould 5 ай бұрын
10/10
@AblyRealtime
@AblyRealtime 4 ай бұрын
Thanks! Glad to hear you liked it!
@rickshawty
@rickshawty 27 күн бұрын
Thanks for the tutorial, I really appreciate the effort. One q tho, r u rly using white mode in vs code?
@AblyRealtime
@AblyRealtime 13 күн бұрын
Alex is just a VS code white-mode kinda guy 😎
@nibunimu
@nibunimu 5 ай бұрын
Why do we use useRef and not useCallback at 57:00?
@AblyRealtime
@AblyRealtime 5 ай бұрын
Good question. To the best of my understanding, useRef is equivalent to useCallback with an empty dependencies array. They both accomplish the same thing, which is to reference a variable between re-renders - Alex
@Goku-xm1gq
@Goku-xm1gq 6 ай бұрын
You said brodcasting using loop ? but that aint feasible right ? when user count is high
@AblyRealtime
@AblyRealtime 6 ай бұрын
Correct - when the user count is extremely high, broadcasting a message to every single client using a loop can lead to performance issues. In such cases, more complex solutions such as pub/sub models or a Message Queue system might be needed. These solutions allow the server to handle a much larger number of connections simultaneously. - Alex
@milon27
@milon27 6 ай бұрын
🎉 how to deploy properly ? in scalable way
@AblyRealtime
@AblyRealtime 6 ай бұрын
Hello, we have another recent video called 'How to scale WebSockets to millions of connections' which you might find helpful: kzbin.info/www/bejne/rImtpH1rZ9uqd6M - let us know if you have any questions
@sandipsarkar1702
@sandipsarkar1702 14 күн бұрын
could you please use dark theme! 😅
@AblyRealtime
@AblyRealtime 13 күн бұрын
we will next time 🥰
@eddieaguilar4878
@eddieaguilar4878 3 ай бұрын
Awesome thing but my eyes are crying with this light IDE 😂
@arifulislamleeton
@arifulislamleeton 4 ай бұрын
Hi I'm Ariful Islam leeton im software developer and website developer and co founder open A. I
@NoNamePerson18
@NoNamePerson18 2 ай бұрын
This guy is a monster, a psychopath, he uses light theme,
@AblyRealtime
@AblyRealtime 2 ай бұрын
🫣
How to scale WebSockets to millions of connections
14:01
Ably Realtime
Рет қаралды 18 М.
Every React Concept Explained in 12 Minutes
11:53
Code Bootcamp
Рет қаралды 350 М.
1❤️
00:20
すしらーめん《りく》
Рет қаралды 25 МЛН
I PEELED OFF THE CARDBOARD WATERMELON!#asmr
00:56
HAYATAKU はやたく
Рет қаралды 38 МЛН
CAN YOU HELP ME? (ROAD TO 100 MLN!) #shorts
00:26
PANDA BOI
Рет қаралды 35 МЛН
Sigma Girl Education #sigma #viral #comedy
00:16
CRAZY GREAPA
Рет қаралды 55 МЛН
WebSockets in 100 Seconds & Beyond with Socket.io
8:31
Fireship
Рет қаралды 953 М.
Don't Use Websockets (Until You Try This…)
6:46
Code With Ryan
Рет қаралды 280 М.
WebSocket - The Easiest and Detailed Explanation
9:35
Coding with Yalco
Рет қаралды 4 М.
This is the Only Right Way to Write React clean-code - SOLID
18:23
How Web Sockets work | System Design Interview Basics
5:28
ByteMonk
Рет қаралды 173 М.
Design patterns in React
14:37
Cosden Solutions
Рет қаралды 139 М.
Get Started Running League Java Programs on the Web
5:05
The LEAGUE of Amazing Programmers
Рет қаралды 6
Websockets in Python
17:52
APMonitor.com
Рет қаралды 24 М.
1❤️
00:20
すしらーめん《りく》
Рет қаралды 25 МЛН