Context API

Built-in React state sharing without prop drilling

← Back

Key Concepts

  • createContext() to define a context
  • Context.Provider wraps components to share state
  • useContext() hook to consume context values
  • Best for theme, auth, and low-frequency updates
  • Avoid performance issues by splitting contexts

Click the icon to change the global theme:
(The same behaviour can be achieve by clicking in navbar )