Updating a Next.js app frontend from the backend

Viewed 115

I'm building a Next.js web application with a "phone verification" flow.

To verify phone numbers, my web app is sending users a text message using Twilio's API.

Then, users can reply to the text message with the word "YES" to confirm their phone number.

This "YES" text message is triggering a webhook within Twilio that is hitting one of my Next.js API endpoints which finally updates the database "verified" field to "true".

so far so good.

I would love for the front end to get redirected or updated once the phone number is verified.

Is there a way to achieve this behavior within Next.js framework? or maybe web sockets, redirect responses, meteorjs, or any other third-party library or service?

(I'm hosting my app on Vercel and GCP)

And, Yes, I know all about the verification code approach lol I'm just trying to avoid this step in my onboarding flow...

Would love to hear your thoughts!

Thanks!

1 Answers

You have several options for develop that.

  1. My first and basic idea would be to create setTimeout, (maybe recursive timeout for some cicles, 15s, 30s, 45s)

  2. My second idea would be use Firebase Firestore, I think this is very better idea that the first, Firestore works like a websocket and in your component or page you can listen Firebase Database until the user write YES then you update your Database and run process for set same response in Firestore.

Sorry my english is not very well.

I hope I've helped.

Related