localStorage persists until it is cleared. sessionStorage normally lasts for the current tab session.
localStorage
localStorage stores string key-value pairs for a specific origin. It is useful for theme settings, small preferences, and local favorites.
sessionStorage
sessionStorage has a similar API but is scoped to the current tab session.
Limits and privacy
Storage capacity is limited and browser policies can block access. Do not use browser storage for passwords or highly sensitive data.
Clearing data
Users can remove stored data through browser settings. Private browsing modes may change persistence behavior.