One Small UX Fix That Actually Helps



This content originally appeared on DEV Community and was authored by Shola Jegede

When I build software, I try to make the app remember things. So the user doesn’t have to do the same stuff over and over.

Most apps reset everything on refresh or when you come back later. That gets annoying fast.

Here’s what I mean:

  • You click the same tab again
  • You re-select your filter or sort
  • You retype the same input or prompt
  • You toggle dark mode every single time
  • You expand the same panel again and again

It’s small stuff, but it adds up. And it makes your app feel worse.

Use localStorage to remember things

I now save small bits of state in localStorage. Just enough so the app feels more stable and consistent.

Here’s what I usually save:

  • Last open tab
  • Dark or light mode
  • Draft input or prompt
  • Filters or sort settings
  • Collapsed/expanded sidebar
  • Dismissed modals or popups (usually the ones that require immediate action)
  • Recently used colors
  • Preview mode (mobile/desktop)
  • Selected language

Nothing too deep or serious, just the things that help someone continue where they left off.

Example: Save and Load Dark Mode

Here’s a basic example using localStorage to save the dark mode setting:

// Save mode
localStorage.setItem('theme', 'dark'); 

// Load mode
const savedTheme = localStorage.getItem('theme'); 
if (savedTheme === 'dark') {
    document.body.classList.add('dark');
}

Or in React:

useEffect(() => {
    const saved = localStorage.getItem('theme');
    if (saved) {
        setTheme(saved);
        // assume setTheme updates UI
    }
}, []);

const toggleTheme = () => {
    const newTheme = theme === 'dark' ? 'light' : 'dark';
    setTheme(newTheme);
    localStorage.setItem('theme', newTheme);
};

Quick Tips

  • Only store things that make the app easier to use
  • Don’t save sensitive info (like auth tokens or personal data)
  • Give users a way to reset preferences if needed
  • Use a small wrapper or custom hook if you’re using this a lot

That’s It

This isn’t a big feature. But it makes your app feel smoother. People don’t notice it when it works — they just stop getting annoyed.

If you’re building something people will use more than once, this matters.

What else are you saving with localStorage that improves UX? Drop your own patterns below. I’m always curious what others are doing.


This content originally appeared on DEV Community and was authored by Shola Jegede