Integrating WebSockets in Nuxt and Nitro

  Рет қаралды 7,773

Alexander Lichter

Alexander Lichter

Күн бұрын

Пікірлер: 100
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
Who was looking forward to WebSockets? 🙌🙌🙌
@Indam1
@Indam1 6 ай бұрын
Wow, I started to work with WebSockets on Nuxt 3-5 hours ago and only now could create a chat. Time to solidify knowledge😁 Thank you for the great videos🔥
@s4ndeep1203
@s4ndeep1203 6 ай бұрын
Suggestion: Would love to have a video by you on Nuxt Layers !
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
Noted 👌🏻
@geek-de3pi
@geek-de3pi 6 ай бұрын
@@TheAlexLichter 1 suggestion nuxt layers with each layer having own local modules
@ZiadMalik-fs7ps
@ZiadMalik-fs7ps 6 ай бұрын
Super relevant video for an app I am working on right now, keep up the good videos! Not enough Nuxt content by far!
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
Perfect! Glad it could help you straight away 🔥 I’ll definitely keep it up with the content! Your Super Thanks is ensuring it can keep going on and I can invest more time into KZbin 🙏🏻 Thank you so much! 🙌🏻
@damiangowala5681
@damiangowala5681 6 ай бұрын
An in-depth guide on Vite PWA for Nuxt would be amazing to see (workbox, caching, custom installation prompt, etc.); currently, there are very few resources on it
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
Noted Damian ✅
@prishanf
@prishanf 4 ай бұрын
Very easy to understand example. I’m loving Nuxt how simple the web socket api is both FE and backend.
@TheAlexLichter
@TheAlexLichter 4 ай бұрын
Delighted to hear that the example was great ☺️ Right? The APIs are so elegant 🔥
@todpale
@todpale 6 ай бұрын
We finally have it in Nuxt! Almost, but still! Thanks for the video!
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
Hope you enjoy it!
@lbmgary
@lbmgary 3 ай бұрын
This is so awesome. Coming from Laravel where they do sooooo much to try to make it easy and, sorry, it just isn't. What a great demo. Rocking a connection with home assistant now turning lights on and off. Going to make it pretty and share it :)
@TheAlexLichter
@TheAlexLichter 3 ай бұрын
Yes please! Definitely share it! Would love to see more examples on it 🔥
@randomtimessomehow
@randomtimessomehow 6 ай бұрын
I love these videos, I'm learning something new everytime :) Keep up the good work
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
Thank you so much Phillip! I highly appreciate it 🙏🏻 Donations like yours will allow me to spend even more time on the channel and such videos 🔥
@silvesterwali6565
@silvesterwali6565 6 ай бұрын
amazing .. video. can you make another video how to handle properly file uploaded in nuxt fullstack. like laravel they can upload assets for public and private. and those asset will not missing/ lose after rebuild project
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
Absolutely! Noted 👌
@joschua6523
@joschua6523 6 ай бұрын
Would love to see a video on IndexedDB and how to handle reactivity while using it!
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
I'd go with idb-keyval and the composable around @ vueuse.org/integrations/useIDBKeyval/ ☺️
@m.h.323
@m.h.323 5 ай бұрын
Still can't wrap my head around the functionality. Tested the demo, which works fine, but that requires everything is in one composable. How would I approach it when I have an existing service, that is listening to events and writes in the DB. I want to get that eventName and push it to the Websocket. Example would be great.
@luc122c
@luc122c 6 ай бұрын
Thanks for another great video! I’m going to have a look at proxying web sockets using nitro
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
You are welcome 🙌🏻 Were you successful? ☺️
@luc122c
@luc122c 6 ай бұрын
@@TheAlexLichter I still have some stuff to workout, it's not going as I expected but that's the fun of living on the edge 😝
@nonameviz
@nonameviz 6 ай бұрын
I already use this + the task feature 🔥 Love you all 💚💚
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
So amazing, right? What do you use it for? ☺️
@nonameviz
@nonameviz 6 ай бұрын
@@TheAlexLichter I have a task that runs every 48hrs to purge unverified accounts for a community website I'm building. The websocket feature to show some kind of progress to the users (some applications have multi stages). Love and good wishes to you all, especially Pooya💚
@TheDigitalSight
@TheDigitalSight 6 ай бұрын
Can you also create video on consuming streaming responses for text & video? For example, How to render responses from OpenAI api or local LLMs?
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
On the list 👍🏻
@TheDigitalSight
@TheDigitalSight 6 ай бұрын
If possible will you create reusable composable we can use? or even better if possible integrate in nuxt core@@TheAlexLichter
@TheDigitalSight
@TheDigitalSight 6 ай бұрын
Also I'll be using OpenAI api next week so may I know when you'll be uploading video for it if possible?@@TheAlexLichter Thanks for teaching gems in nuxt ♥
@MissedWarrior
@MissedWarrior 6 ай бұрын
Firefox also has WebSocket debugging tool in response tab but since there were no messages after connection it simply showed that there were no messages 😅 Thanks for the vid!
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
Good point! Thanks for the heads up 😊
@nanaassumadu4997
@nanaassumadu4997 6 ай бұрын
Thank you...This is awesome... I will definitely implement this in all my Nuxt project as a way to get feedback from my users Thanks a lot
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
You are welcome! How did the implementation go?
@SKTTWkartrider
@SKTTWkartrider 6 ай бұрын
Rare video that Alex filmed during day
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
Well spotted! I did today as I was busy writing my thesis until Wednesday 👀😁
@svenvanreenen
@svenvanreenen 6 ай бұрын
This is really cool. I dont have much experience with websockets, so I have a storage question. How long will messages be stored, as long as the server runs? or should they be saved in a DB?
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
As mentioned in a comment earlier - the messages must be saved externally to be persisted. WebSockets are only a way to communicate and do not persist data by default 😊
@ralacerda12
@ralacerda12 6 ай бұрын
This is amazing. But if I'm building a chat application I would need to save the messages somewhere (using unstorage), right? If I have a array on the top of the 'websocket.ts' file, will that be avaliable for all instances of the websocket? Also, I'm assuming this cannot be deployed on serverless, right?
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
Yes, saving would be helpful, eg in a KV store or even a database. Check out Nitros db0 layer or unstitched as you mentioned A external variable would work as „in-memory storage“ but I’d not recommend that as you can’t share it across instances (Better use a kv then)
@valacshiro378
@valacshiro378 6 ай бұрын
Thank you, this is amazing I love your vids they are always helpful
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
Happy to help! 🙏🏻
@trinhnam3117
@trinhnam3117 6 ай бұрын
Your video is very helpful, thank you. Can you share how to handle authentication with Nuxt3, I'm looking forward to it ^^
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
Glad to hear 🙏🏻 Auth is on the list, yes. But unfortunately a *very broad* topic to cover. So many ways to do auth 🙈
@randomtimessomehow
@randomtimessomehow 6 ай бұрын
I love these videos, I'm learning something new everytime :) I have a general question... Let's say I would actually have to build a chat functionality in my web app (luckily I don't!) in combination with Supabase. Supabase has a subscribe feature (I'm not sure if you're familiar with it). Could I develop such chat functionality solely with Supabase subscribe feature (so I can automatically retrieve new messages in realtime) or would I need the web socket handler on top of that?
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
Glad to hear that the videos are helpful 🙏🏻 Regarding your question: Yes, you could implement that with Supabase only as they provide the logic for broadcasting out of the box 👍🏻
@randomtimessomehow
@randomtimessomehow 6 ай бұрын
Thanks again! 🙏🏻@@TheAlexLichter
@QueeeeenZ
@QueeeeenZ 6 ай бұрын
Can you do a video about Nitro Tasks?
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
Sure! Wrote it on the list 👌🏻
@sematoghem
@sematoghem 6 ай бұрын
finally... this feature is so simple but long time to do. you can use socketio but it so not native and the bad thing is it work in dev but not in prod!!!!
@TheAlexLichter
@TheAlexLichter 5 ай бұрын
It is actually pretty "tricky" given the runtime-agnostic approach. In "node only" it'd be simple though, yes.
@michaelpeters9551
@michaelpeters9551 3 ай бұрын
You are awesome thank you!
@TheAlexLichter
@TheAlexLichter 3 ай бұрын
Thank you so much 🙏🏻
@夕阳子
@夕阳子 6 ай бұрын
Really cool video. can you do a video about Nuxt test?
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
Yes, soon!
@productdevbook
@productdevbook 6 ай бұрын
Thank you ❤
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
You are welcome 🙏🏻
@leestevenscoder
@leestevenscoder 6 ай бұрын
Great stuff. Many thanks to Alex for being so cutting edge with Nuxt. But does anyone know why "useWebSocket is not defined"? Even when i get the same output from `pnpm why nuxi-nightly` as the video.
@leestevenscoder
@leestevenscoder 6 ай бұрын
because I need to `pnpm i @vueuse/core` and import from that
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
Should be auto imported when using the nuxt module (shown in the config beforehand) ☺️
@leestevenscoder
@leestevenscoder 6 ай бұрын
Yes. There it is 😂
@dracula5752
@dracula5752 3 ай бұрын
how do you disconnect or not allow connect to websockets if they are not authenicated?
@Gornius
@Gornius 6 ай бұрын
Can you do the same with Server Sent Events? It's uni-directional (server-to-client), but works on the same protocol (HTTP).
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
SSE also work with nitro, yes!
@miguelcassimiro8103
@miguelcassimiro8103 2 ай бұрын
Could an external API send a request to the websocket?
@miguelcassimiro8103
@miguelcassimiro8103 2 ай бұрын
Love the usage of Brazilian meme lol
@Shulkerkiste
@Shulkerkiste 6 ай бұрын
Firebase is listed at 1:20 In which way will it be supported? Does Firebase support Websockets?
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
Firebase is listed as "needs investigation", meaning no guaranteed support at the time of recording Follow along github.com/unjs/nitro/issues/2171 (+ get involved if possible! 🙌😊)
@iUmerFarooq
@iUmerFarooq 6 ай бұрын
That's cool 🔥
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
Oh yess 🔥
@RonGeorgePile
@RonGeorgePile Ай бұрын
Does anyone have a Nuxt chat app that works on production? Which hosting platform did you use? I'm currently stuck after deploying to Netlify which can't support web sockets
@TheAlexLichter
@TheAlexLichter Ай бұрын
Check out github.com/unjs/nitro/issues/2171 for supported platforms!
@jurarexx
@jurarexx 5 ай бұрын
Is there a way to send message to websocket from server-side?
@TheAlexLichter
@TheAlexLichter 5 ай бұрын
You probably can by setting up a node websocket client, sure.
@devoxygen7395
@devoxygen7395 6 ай бұрын
Lub dude
@Zyk0tiK
@Zyk0tiK 6 ай бұрын
I downloaded your example code from GitHub but I am unable to get it to connect to websockets with npm run dev, I have to build it and run it with node. Any ideas?
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
As mentioned from 00:50 on, make sure you use the nightly build of nuxt + nuxi which are necessary at the moment 😊
@Zyk0tiK
@Zyk0tiK 6 ай бұрын
@@TheAlexLichter I used your code from github and did an npm install on it. The package.json says it's using nuxt-nightly... am I missing something else? Aha, I see. `npx nuxi-nightly dev` to run it. All good!
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
It should also run fine with `npm run dev` in there 😊
@iUmerFarooq
@iUmerFarooq 6 ай бұрын
Why we can't call https api in nuxt server. It gives ssl issue. How and when it will solve?
@svenvanreenen
@svenvanreenen 6 ай бұрын
I can without issues. $fetch working great in nitro server.
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
You might need NODE_TLS_REJECT_UNAUTHORIZED='0', see e.g. github.com/nuxt/nuxt/issues/26222
@iUmerFarooq
@iUmerFarooq 6 ай бұрын
@@TheAlexLichter Yeah it's work. If possible please make a tutorial on it. Thanks a lot 💚
@carlotadias9335
@carlotadias9335 2 ай бұрын
🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉
@some_body_qtyeeuy
@some_body_qtyeeuy 6 ай бұрын
Здарова Лёха!
@TheAlexLichter
@TheAlexLichter 5 ай бұрын
Heyy!
@undertale-15075O
@undertale-15075O 6 ай бұрын
Не надо дядя, не надо 😮
@DougLopes
@DougLopes 5 ай бұрын
holy 4 min of explanation and config to use this, doesn't look trustable
@TheAlexLichter
@TheAlexLichter 5 ай бұрын
How long do you usually spend time reading the docs + implementing the learnt knowledge? I bet more than 4 minutes 😁
@DougLopes
@DougLopes 5 ай бұрын
@@TheAlexLichter absolutelly yes, just saying that looks unsafe for prod if is so experimental.
@TheAlexLichter
@TheAlexLichter 5 ай бұрын
Ah well, a fair point to use it carefully but it works fine! Just make sure to pin the version in case changes come 🙌🏻
@lcapocer
@lcapocer Ай бұрын
This is not working for me. First of all it says useWebSocket is not defined hence I needed to pnpm i @vueuse/nuxt @vueuse/core and now it says "Cannot read properties of undefined (reading 'host')" :(
@lcapocer
@lcapocer Ай бұрын
ok apparently I needed to adjust the path to the websocket 🤦
@TheAlexLichter
@TheAlexLichter Ай бұрын
Glad you got it resolved 😋
Faster Nuxt Builds? 🤔 No problem ✅
15:40
Alexander Lichter
Рет қаралды 3,1 М.
How to scale WebSockets to millions of connections
14:01
Ably Realtime
Рет қаралды 27 М.
Стойкость Фёдора поразила всех!
00:58
МИНУС БАЛЛ
Рет қаралды 6 МЛН
Incredible: Teacher builds airplane to teach kids behavior! #shorts
00:32
Fabiosa Stories
Рет қаралды 11 МЛН
How Strong is Tin Foil? 💪
00:26
Preston
Рет қаралды 153 МЛН
Why you should use useState()
17:57
Alexander Lichter
Рет қаралды 18 М.
5 Signs of an Inexperienced Self-Taught Developer (and how to fix)
8:40
Don't Use Websockets (Until You Try This…)
6:46
Code With Ryan
Рет қаралды 305 М.
Caching in Nitro 💾
22:53
Alexander Lichter
Рет қаралды 3,2 М.
Why I Don't Use NextJS For My Side Project Anymore
6:51
Josh tried coding
Рет қаралды 72 М.
🚨 Dependency warnings in a fresh Nuxt application?
15:49
Alexander Lichter
Рет қаралды 2,1 М.
The BEST way to proxy your API in Nuxt
21:12
Alexander Lichter
Рет қаралды 17 М.
Unnecessary Comparison 🤦 Next.js vs Vue.js | Jelvix
6:09
Jelvix | TECH IN 5 MINUTES
Рет қаралды 6 М.
WTF are WebSockets
11:37
Directus
Рет қаралды 1,7 М.
Fast and Simple Web Apps with Nitro JS
5:08
Rob Conery
Рет қаралды 4,2 М.
Cómo pensaba que sería el iPhone 16 😭
0:12
Alan
Рет қаралды 2,1 МЛН
Выпрыгивает ли аккумулятор в iPhone 16?
0:43
ÉЖИ АКСЁНОВ
Рет қаралды 3,7 МЛН
🤔Как правильно держать iPhone? 📱
0:46
Не шарю!
Рет қаралды 561 М.
Evolution of the Samsung Galaxy
0:50
ios_aesthetics
Рет қаралды 7 МЛН