zustand-slices-pattern-for-scalability
Installation
SKILL.md
Zustand Slices Pattern for Scalability
When to Use Slices
Use the slice pattern when:
- Store exceeds 150 lines of code
- Store has more than 10 actions
- Related features should be co-located
- Multiple developers work on different parts of state
- You need better code organization and maintainability
Slice Definition Pattern
A slice is a function that accepts set and get and returns a portion of the store:
import { StateCreator } from 'zustand';