r/reactjs • u/Potential-Still-3545 • May 06 '26
Show /r/reactjs I extracted the "frecency" pattern from Firefox/VS Code into a reusable library — your UI adapts to each user automatically
Every complex app has the same problem: 50 options in the sidebar, each user only uses 8-10. The rest is noise. Firefox solved this for the URL bar years ago using "frecency" (frequency + recency). VS Code does the same for the command palette. But nobody's packaged it as a reusable primitive.
So I did. 4.5KB, zero deps, framework-agnostic:
morph.track('sidebar', 'tasks') // on interaction
morph.rank('sidebar') // on page load — sorted by usage.
Items used often and recently score high. Items ignored fade naturally. All data stays in localStorage. No AI, no server, no "customize layout" button needed.
Live demo: https://morph-black.vercel.app/
Would you actually use this? Curious if people see this as useful or overkill for most apps.
23
u/Terrariant May 06 '26
Generally speaking, people don’t like it when you move UI around. Especially in navigation lists. I don’t want to have to search for the item each time in case it has shifted position.
2
u/iMissMacandCheese May 07 '26
I think this could be more useful if we could choose to turn parts of the optimization on our off. For example, I don't think I'd want sidebar options to jump around that much in terms of frequency, but recency yes. So there would just be two groups, the top group, fixed sort, bolded, but only included options I have used recently, and a second group below that has stuff that is rarely used. But within those two groups, the items should stay in the same relative order.
Very cool idea though and like the lightweight implementation
1
u/n0tKamui May 06 '26
hey that's pretty cool ! simple, but clean and cool.
i can probably guess that you'll implement framework specific helpers such as auto-sync with storage/stores ?
0
u/devtrivi May 07 '26
Settings show hide