Communication with server and client <nextjs>

i have a webhook which calls nextjs api, can that api call do something which triggers an action on
17 Replies
albatroz
albatrozOP9mo ago
@nyx (Rustular DevRel) hey, could you help me understand the flow?
Neto
Neto9mo ago
are you using vercel?
albatroz
albatrozOP9mo ago
yes
Neto
Neto9mo ago
then no you will need pooling
albatroz
albatrozOP9mo ago
ohh
Neto
Neto9mo ago
or use a external service for sockets
albatroz
albatrozOP9mo ago
so the platform's webhook will call the api of nextjs, and not sure after that
Neto
Neto9mo ago
the base line is the following
No description
Neto
Neto9mo ago
WS can be pusher or socketi, as a example
albatroz
albatrozOP9mo ago
do nextjs has websocket ?
Neto
Neto9mo ago
vercel runs on lambdas/workerd so no websockets from nextjs without running on a server 100% pusher is the easiest thing
albatroz
albatrozOP9mo ago
GitHub
GitHub - pusher/docs: The all new Pusher docs, powered by @11ty and...
The all new Pusher docs, powered by @11ty and @vercel - pusher/docs
Neto
Neto9mo ago
yeah
// on the API route that receives the webhook request
pusher.trigger('my-channel', 'my-event', {
"message": "hello world"
});

// on the client side
// connect to pusher and listen to events
// on the API route that receives the webhook request
pusher.trigger('my-channel', 'my-event', {
"message": "hello world"
});

// on the client side
// connect to pusher and listen to events
albatroz
albatrozOP9mo ago
understood Thanks
Neto
Neto9mo ago
np
Bohdan
Bohdan9mo ago
if this webhook happens as a consequence of a client side action, you could do polling i.e. make a request to the backend every N seconds to check for your api action
Bohdan
Bohdan9mo ago
here's an in-depth explanation of the polling approach https://youtu.be/ZPh2Hapjd64?si=pAKZhQnA8e2_ZYm1
Web Dev Cody
YouTube
This is why you'll need polling in your web applications
give Hosna a follow: https://www.youtube.com/@hqasmei --- my courses --- 📘 T3 Stack Tutorial: https://1017897100294.gumroad.com/l/jipjfm --- my products --- 📖 ProjectPlannerAI: https://projectplannerai.com 🤖 IconGeneratorAI: https://icongeneratorai.com/ --- useful links --- 💬 Discord: https://discord.gg/4kGbBaa 🔔 Newsletter: https://newslette...
Want results from more Discord servers?
Add your server