Course contentsShow
← React
Lesson 1707 of 2,39641. State Management EcosystemFree lesson

Zustand's Philosophy: No Provider, No Context

Understanding how Zustand differs from Context by storing state outside React's tree entirely.

Zustand's Philosophy: No Provider, No Context

You'll learn: How Zustand fundamentally differs from React Context by storing state completely outside React's component tree.

The Core Philosophical Difference

While React Context requires a Provider component wrapping your tree and passes state down through the component hierarchy, Zustand takes a radically different approach: it stores state in a plain JavaScript module outside React entirely.

Think of it this way: Context is like passing a baton through a relay race of components. Zustand is like putting a whiteboard on the wall that any component can walk up to and read or update directly — no chain of handoffs needed.

How This Works

With Zustand, you create a store using a simple function:

import create from 'zustand'

const useStore = create((set) => ({
  count: 0,
  increment: () => set((state) => ({ count: state.count + 1 }))
}))

Any component can then access this store directly:

function Counter() {
  const count = useStore((state) => state.count)
  const increment = useStore((state) => state.increment)
  
  return <button onClick={increment}>{count}</button>
}

No Provider wrapping. No Context drilling. The store exists independently, and components subscribe to it via a hook.

Why This Matters

This architecture eliminates the Context Provider tax: you don't need wrapper components, you don't have to think about Provider placement, and there's no Context nesting complexity. The state simply exists, and components opt into it when needed.

Key Takeaway: Zustand avoids React's Context system entirely by storing state in a module-level singleton, letting components subscribe directly without Providers or prop drilling.