persist middleware
Zustand's wrapper that saves the store to storage after every change and restores it on launch. With createJSONStorage over AsyncStorage, only the data is written as JSON; version and migrate upgrade old saved shapes.
Minimal example
persist(storeFn, { name: "cart", storage: createJSONStorage(() => AsyncStorage) })Learn this concept
Lesson 4.12 · Persisting Zustand stateUsed in exercises
Exercise 4.13 · Persisted cart store Exercise 4.16 · Cart screen Exercise 4.21 · Cart synchronization helperPrerequisite conceptsZustand
RelatedHydration