Problem: When a user shares or bookmarks a URL, the page doesn't show what...
Problem:
When a user shares or bookmarks a URL, the page doesn't show what they were seeing when reloaded.
Solution:
Consider storing the state in the URL.
Examples:
✅ Currently selected tab
✅ Accordion open/closed status
✅ Search, sort, filter, pagination settings
✅ Scroll position via a page anchor link

Stuff that doesn't belong in the URL:
🚫 Passwords and other sensitive user-specific info
🚫 State that is ephemeral, and thus, wouldn't make sense to display again later if loaded via a bookmark.
Concern: If I update the URL every time a tab is clicked or an accordion is opened, won’t that lead to a “messy” browser history when the user clicks the back button?
Solution: You can avoid a messy history by using replaceState when updating the URL.
https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState