# @dojoengine/recs

> `recs` is built with reactivity in mind. `Components` and `Queries` expose an `update$` stream, that `Systems` can react to.

Latest version **2.1.0** (published 2026-04-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install @dojoengine/recs
pnpm add @dojoengine/recs
yarn add @dojoengine/recs
bun add @dojoengine/recs
```

## Health

**Score 50/100 (C)** — status: stable.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 2.1.0 |
| Published | 2026-04-22 |
| First published | 2023-11-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Dependencies | 4 |
| Unpacked size | 266.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | realm_lord |

## Links

- npm: https://www.npmjs.com/package/@dojoengine/recs
- Repository: https://github.com/dojoengine/mud
- Homepage: https://github.com/dojoengine/mud/tree/main/packages/recs#readme
- Issues: https://github.com/dojoengine/mud/issues
- npm.io page: https://npm.io/package/@dojoengine/recs

## Dependencies (4)

- [mobx](https://npm.io/package/mobx.md) ^6.7.0
- [rxjs](https://npm.io/package/rxjs.md) 7.5.5
- [@latticexyz/utils](https://npm.io/package/@latticexyz/utils.md) ^2.2.23
- [@latticexyz/schema-type](https://npm.io/package/@latticexyz/schema-type.md) ^2.2.23

## Recent versions

- 2.1.0 (latest) — 2026-04-22
- 2.0.13 — 2024-06-20
- 2.0.12 — 2024-06-20
- 0.1.35 — 2023-11-07

## README

# recs - Reactive Entity Component System

`recs` is built with reactivity in mind.
`Components` and `Queries` expose an `update$` stream, that `Systems` can react to.

To build some fundamental intuition about ECS, have a look at [our MUD ECS introduction](https://mud.dev/blog/ecs).

`recs` is seamlessly integrated with the other MUD libraries, but can be used independently.

For detailed documentation, check out [mud.dev/recs](https://mud.dev/recs).

# Features

- Reactive components, queries, and systems
- Powerful queries, including advanced indirect relationship queries
- Seamless integration with other MUD libraries and services
- Simple, declarative API
- Ultra high performance
- TypeScript support

# Example

```typescript
import {
  createWorld,
  defineComponent,
  createEntity,
  withValue,
  defineSystem,
  Has,
  getComponentValue,
  setComponent,
} from "@latticexyz/recs";

// Create a new World
const World = createWorld();

// Define a couple components
const Position = defineComponent(world, { x: Type.Number, y: Type.Number });
const Movable = defineComponent(world, { speed: Type.Number });

// Create a new entity
const entity1 = createEntity(world, [withValue(Position, { x: 0, y: 0 }), withValue(Movable, { speed: 10 })]);

// Define a system that reacts to updates of movable entities with a position
defineSystem(world, [Has(Position), Has(Movable)], (update) => {
  console.log("Entity", update.entity, "moved to", update.value);
  // ... do stuff, like rendering the entity on the screen, etc
});

// Move the entity around
setInterval(() => {
  const currentPosition = getComponentValue(Position, entity1);
  const newPosition = { x: position.x + 1, y: position.y + 1 };
  setComponent(Position, entity1, newPosition);
}, 1000);
```

# Acknowledgements

- Syntax originally inspired by [bitECS](https://github.com/NateTheGreatt/bitECS)

---
_Source: https://npm.io/package/@dojoengine/recs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
