Skip to content
public-library›Rules›Zustand›Create stores once, outside render

Create stores once, outside render

Create client-side Zustand stores once, at module scope, in a dedicated store module. When each component instance or server request needs its own store, create a vanilla store once per instance and provide it through React context.

In the full rule