Vikram Khemlani
Vikram Khemlani

Reputation: 635

Create a webhook between my front end and back end

So from what I understand about webhooks, I keep looking up "How to create a webhook from my API" but the results keep giving me how to add a webhook (From say GitHub) from different sites. I'm not sure if this is possible but currently, my react native app polls my node js backend for information every minute. Instead, I want my node js backend to detect a change in my database for a specific user, and then send that updated information to my react native app user. Is this possible, does anyone have any guidance or direction, even a link because all the information I find online is not what I want? Are there any third-party apps that could help in this process? What would I need to do exactly?

Upvotes: 4

Views: 9771

Answers (2)

zmcmahon
zmcmahon

Reputation: 431

No, you won’t be able to have a webhook call back to the react app. The app runs within a secure browser, on a secure operating system, on a secure network. At least, hopefully, it runs in a secure environment.

Your in-browser app does not run a web server so even if there was a network route to your machine, how would you receive it? You’d need to bind to a network port somehow. Not gonna happen.

Instead, look into WebSockets or HTTP2 Server-Sent Events (SSE). They allow the servers to push data to a frontend web app running in the browser. It’s not technically webhooks, but the same concept.

Upvotes: 11

user22802185
user22802185

Reputation: 11

use websockets for this, it's ok for your task

Upvotes: 0

Related Questions