Urgent.News

What's breaking now, across thousands of outlets.

Tech

Your Global Store Is a Junk Drawer. Sort State Into Four Boxes First

If everything lives in the store, nothing really lives in the store. I have watched senior engineers, people with a decade on their resume, answer "how do you structure state in a complex app" by describing one giant global store. Server data, form inputs, a sidebar toggle, a cached auth token, all of it swimming in the same tank like it is 2016 and we are still doing it for the aesthetic. It is…

In today's software development, single global stores are often used to hold all state within an application. However, this approach quickly leads to a messy, hard-to-maintain codebase. The key to structuring state effectively is sorting items into four distinct categories: server state, URL state, local UI state, and persisted state.

Server state consists of data fetched from a backend, such as database information or API responses. It should be treated like a cache, using tools like query libraries with stale-while-revalidate mechanisms rather than being managed directly by reducers. There's no need to hand-write complex state management logic in 2026.

URL state represents data that can be shared through a link, such as search filters, selected tabs, or pagination settings. Query parameters provide an underutilized, free option for persisting this data across page refreshes and enabling deep linking.

Local UI state pertains to component-specific information that doesn't need to travel across the application. For example, a modal open flag should be managed within the component that uses it, rather than being part of a global store.

Persisted state refers to data that needs to survive a user reload. This includes cached versions of previous sessions and should be stored using mechanisms like localStorage or IndexedDB, with proper hydration plans and expiry strategies.

The crucial decision rule is to classify each state item into one of these four boxes before considering a global store. If a piece of state doesn't fit neatly into any category, it likely doesn't belong in a shared store in the first place. After sorting, the remaining shared, client-owned state comprises the true purpose of your application's store. By following this simple rule, you can dramatically reduce store bloat and create a cleaner, more maintainable codebase.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Oh Dear alternative? Uptime green is not Core Web Vitals portfolio monitoring

The uptime dashboard is green, SSL is fine, and the status page is quiet, yet a client still forwards a PageSpeed Insights screenshot where mobile Largest Contentful Paint sits in Needs improvement.

  • Uptime green does not guarantee good Core Web Vitals performance
  • Largest Contentful Paint (LCP) needs improvement despite green uptime
  • Uptime and Core Web Vitals are distinct metrics, not interchangeable

More from Tuesday 6 October →