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:

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:

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

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.