Skip to content
Back to skills

Zustand Entities

ASecurity

Use Zustand as a simple state store for entity management (not a true ECS).

  • 31 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added May 27, 2026
developmentgoreactgit

Security analysis

A100/100

Scanned May 27, 2026

npx -y skills add verekia/r3f-gamedev --skill zustand-entities --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Zustand Entities?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Zustand Entities
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/verekia-zustand-entities/badge)](https://www.skillsdirectory.com/skills/verekia-zustand-entities)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: zustand-entities
description: Use Zustand as a simple state store for entity management (not a true ECS).
---

# Zustand Entities

Use Zustand as a simple state store for entity management.

## Technique

Store entities in a Zustand store array. Systems read from the store directly (non-reactively) in `useFrame`, while React components subscribe to the store for re-rendering when entities are added or removed.

## Key Concepts

- Not a true ECS, but simple and effective for many cases
- Store entities in an array with `create()`
- Use `getState()` in systems for non-reactive access (no re-renders)
- Use `useStore(selector)` in components for reactive updates
- Memoize entity components to prevent unnecessary re-renders
- Re-renders happen when entities are added/removed from the array

## Usage

```tsx
const useWorldStore = create(() => ({
  characters: [] as CharacterEntity[],
}))

// In systems (non-reactive)
useFrame(() => {
  for (const char of useWorldStore.getState().characters) {
    char.position.x += 0.01
  }
})

// In React (reactive)
const characters = useWorldStore(s => s.characters)
return characters.map(c => <Character key={c.id} entity={c} />)
```

## Trade-offs

- Simple to understand and implement
- No automatic querying - must manually specify which entities to iterate
- Good for smaller games or prototypes

---

This skill is part of [verekia](https://x.com/verekia)'s [**r3f-gamedev**](https://github.com/verekia/r3f-gamedev).

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.