← Lessons

quiz vs the machine

Gold1320

Frontend

The Zustand Minimal Store

A tiny hook based store with selectors and no provider boilerplate.

4 min read · core · beat Gold to climb

What it is

Zustand is a small state management library built around a single create call that returns a hook. There is no provider to wrap your tree and no action type ceremony.

How it works

The create function receives set and get. You define state fields and the functions that update them. Components call the hook with a selector to read just the slice they need.

  • set: merges a partial update into the store.
  • get: reads the current state inside actions.
  • selector: picks the minimal data a component needs.

Why selectors matter

A component that selects one field only re renders when that field changes. Reading the whole store would re render on any change. Pairing a selector with a shallow equality check keeps updates tight.

  • No context provider required.
  • State and actions live together.
  • Subscriptions are scoped by selector.

Key idea

Zustand gives you a provider free hook store where selectors scope subscriptions so components re render only on the data they actually use.

Check yourself

Answer to earn rating on the learn ladder.

1. What does passing a selector to a Zustand hook achieve?

2. What boilerplate does Zustand notably avoid?