zustand

Installation
Summary

Zustand state management patterns and conventions for LobeHub store development.

  • Three-tier action hierarchy: public actions for UI, internal actions for business logic, and dispatch methods for state updates; use reducer pattern for complex state and simple set for primitives
  • Optimistic update pattern for non-destructive operations: update frontend immediately, call backend service, then refresh for consistency
  • Class-based action implementation using private fields and flattenActions for composition; migrate away from plain StateCreator objects toward encapsulated, type-safe action classes
  • Naming conventions for actions (verb form for public, internal_ prefix for logic, internal_dispatch* for updates) and state (ID arrays, maps, active flags, init flags)
SKILL.md

LobeHub Zustand State Management

Action Type Hierarchy

1. Public Actions

Main interfaces for UI components:

  • Naming: Verb form (createTopic, sendMessage)
  • Responsibilities: Parameter validation, flow orchestration

2. Internal Actions (internal_*)

Core business logic implementation:

  • Naming: internal_ prefix (internal_createTopic)
  • Responsibilities: Optimistic updates, service calls, error handling
  • Should not be called directly by UI
Related skills

More from lobehub/lobehub

Installs
2.0K
Repository
lobehub/lobehub
GitHub Stars
77.2K
First Seen
Jan 27, 2026