I’m building a Twitter-like social media app using Next.js 15 and Supabase. Unlike Twitter, I’m sticking to a unified Home timeline that shows all global posts to everyone (discovery-focused). I'm trying to avoid using expensive services like getStream, etc., to do this, for now.
I'm stuck on how to implement the features mentioned in the title:
The home feed: unlike Twitter, I'm using a unified home feed that shows all global posts to everyone (discovery-focused). I'm confused about what the discovery algorithm should be. I'm also using useSWRinfinite for infinite scroll, so how do I handle DOM bloat? Virtualisation, or just a "hard limit" at ~500 items to force a refresh? And instead of automatically adding posts to the feed, I want to do it periodically and only if the user wants to, as Twitter does by showing the "show x new posts" floating banner at the top of the feed and only adding new posts when I click it. How do I do this?
View count tracking: Planning to use IntersectionObserver to hit an RPC when a post is viewed. Is this too much write volume for a standard DB? Should I be batching these?
Want to know how you guys would implement these and the best practices around implementing these features. would also love to know if there are any better libraries or services that make the job easier.
Any help is appreciated. Thanks in advance!!
Top comments (0)