Zustand or Context state resets on page refresh: persist the slice you need
@devsingh05▲ 9 net votes
In-memory React state, Context and Zustand stores start fresh on every load. For things that must survive a refresh (cart, draft text, onboarding step), use Zustand's persist middleware (localStorage by default) or write the value to localStorage yourself, versioning the stored shape. Keep auth tokens in the auth library's own storage, and never persist secrets.