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
albatrozOP7mo ago
@nyx (Rustular DevRel) hey, could you help me understand the flow?
Neto
Neto7mo ago
are you using vercel?
albatroz
albatrozOP7mo ago
yes
Neto
Neto7mo ago
then no you will need pooling
albatroz
albatrozOP7mo ago
ohh
Neto
Neto7mo ago
or use a external service for sockets
albatroz
albatrozOP7mo ago
so the platform's webhook will call the api of nextjs, and not sure after that
Neto
Neto7mo ago
the base line is the following
No description
Neto
Neto7mo ago
WS can be pusher or socketi, as a example
albatroz
albatrozOP7mo ago
do nextjs has websocket ?
Neto
Neto7mo ago
vercel runs on lambdas/workerd so no websockets from nextjs without running on a server 100% pusher is the easiest thing
albatroz
albatrozOP7mo 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
Neto7mo 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
albatrozOP7mo ago
understood Thanks
Neto
Neto7mo ago
np
Bohdan
Bohdan7mo 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
Bohdan7mo 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