global state

Data kept where any part of a program can read and change it, such as a module-level variable or an app-wide store.

In more detail

Global state is convenient for data truly shared across a program, but it hides where changes come from. On a server, one process handles many requests at once, so request data kept in global state can leak into another request. In user interfaces, libraries such as Redux or Zustand hold global state, and changes to it can cause wide re-renders. Passing data explicitly, or keeping it close to where it is used, avoids many of these problems.

Related terms

Taught in

References