Notifications dropdown that live-updates with Turbo Streams

2644
0

For a notifications dropdown, I keep the list server-rendered and let Turbo Streams keep it fresh. The dropdown content sits in a turbo_frame_tag (so you can also navigate to a full notifications page), and the unread badge is a separate small target that can be replaced. When a notification is created, I broadcast a prepend to the list and a replace to the badge counter. This gives users instant feedback without polling. The implementation is just partials and broadcast_* calls, which means it’s easy to keep styles and accessibility consistent. I also like to broadcast a “mark read” result so multiple tabs stay in sync.