Discussion

Ask HN: How Can I Make My Front End React to Database Changes in Real-Time?

I'm exploring ways to make my frontend applications reactive to database changes without overloading the backend.

- Traditional methods like polling are resource-intensive and rerun entire queries, which isn't efficient. - I’m familiar with some libraries and companies are doing this by building materialized views close to the DB [1][2], but I want to update the frontend, not just the backend. - Some platforms like Supabase Realtime [3] and Firebase offer subscription models to database changes, but these solutions fall short when dealing with complex queries involving joins or group-bys.

My vision is that the modern frontend to behave like a series of materialized views that dynamically update as the underlying data changes. Current state management libraries handle state trees well but don't seamlessly integrate with relational or graph-like database structures.

The only thing I can think of is to implement it by myself, which sounds like a big PITA.

Anything goes, Brainstorm with me. Is it causing you headaches as well? Are you familiar with an efficient solution? how are you all tackling it?

[1] https://readyset.io/ [2] https://materialize.com/ [3] https://supabase.com/docs/guides/realtime/postgres-changes [4] https://github.com/hasura/graphql-engine/blob/master/architecture/live-queries.md

38 points bruchim 2 years ago 54 comments

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton