lobehub avatar

Zustand

This codifies LobeHub's three-layer Zustand architecture: public actions for UI calls, internal_* methods for business logic with optimistic updates, and internal_dispatch* reducers for state mutations. The real value is in the patterns: when to use reducers versus simple set calls, how to handle optimistic updates for maps like messagesMap and topicMaps, and the ongoing migration from plain StateCreator objects to class-based actions with flattenActions composition. If you're working in src/store/**, this gives you the naming conventions and structural rules the codebase actually follows, including the newer class pattern with private fields and explicit store augmentation types for cross-slice dependencies.

skills.sh installs
1.4K
GitHub stars
79.8K
last updated
Jul 14, 2026

Install

$ npx -y skills add lobehub/lobe-chat --skill zustand --agent claude-code

Installs into .claude/skills of the current project.

Files

LobeHub Zustand State Management

State Shapes and Types

  • Import shared store types from @lobechat/types, not @lobechat/database.
  • Keep lightweight list-item types separate from full detail types; list types must not extend heavy detail types.
  • Key cached details by id (xxxDetailMap: Record<string, Detail>); never hold a single currentDetail object.
  • Read through xxxSelectors aggregates (selectors.ts), not ad-hoc lambdas repeated across components.
  • Before choosing list/detail shapes or type sources, read Data structures.

State-Only Stores (default for new and migrated stores)

Actions stay out of the Zustand state. Reference: src/store/page.

Sponsors

Details

Repository
github.com/lobehub/lobe-chat
Category
Frontend Development
First seen
May 16, 2026

More from lobehub/lobe-chat

All 16
1quodsoler avatarue-actor-component-architecturequodsoler/unreal-engine-skillsUse this skill when working with Actor and component design in Unreal Engine. Triggers on: Actor, component, BeginPlay, Tick, SpawnActor, lifecycle, CreateDefau1.4Kskills.sh installs
2hyva-themes avatarhyva-alpine-componenthyva-themes/hyva-ai-toolsWrite CSP-compatible Alpine.js components for Hyvä themes in Magento 2. This skill should be used when the user wants to create Alpine components, add interacti1.3Kskills.sh installs
3martinholovsky avatarwindows-ui-automationmartinholovsky/claude-skills-generatorExpert in Windows UI Automation (UIA) and Win32 APIs for desktop automation. Specializes in accessible, secure automation of Windows applications including elem1.3Kskills.sh installs
4existential-birds avatarreact-flowexistential-birds/beagleReact Flow (@xyflow/react) for workflow visualization with custom nodes and edges. Use when building graph visualizations, creating custom workflow nodes, imple1.3Kskills.sh installs
5jezweb avatarreact-nativejezweb/claude-skillsReact Native and Expo patterns for building performant mobile apps. Covers list performance, animations with Reanimated, navigation, UI patterns, state manageme1.3Kskills.sh installs
6reactjs avatarreact-expertreactjs/react.devUse when researching React APIs or concepts for documentation. Use when you need authoritative usage examples, caveats, warnings, or errors for a React feature.1.3Kskills.sh installs