N
Neon3w ago
unwilling-turquoise

How to implement real-time notifications with Next.js and Neon database?

Hi everyone, I’m building a real-time application using Next.js, and I need to implement a feature where users receive notifications (e.g., updates or messages) in real-time. The notification content is stored in a table in my database. I’m using Neon (Postgres) as my database, but so far, I haven’t found a good solution for implementing this feature with it. Is there a recommended approach or best practice for achieving real-time notifications in this setup? Ideally, I’d like to notify users immediately when a new record is inserted or updated in the database. Any help, examples, or suggestions would be greatly appreciated. Thank you!
1 Reply
automatic-azure
automatic-azure3w ago
Hello! Sounds like you need pub-sub. Postgres's LISTEN and NOTIFY should be more than enough for your use case. This guide here might a good start : https://neon.com/guides/pub-sub-listen-notify You'll need to host the listening process on a 24/7 on service, serverless functions will not suffice for this.

Did you find this page helpful?