Installation

Get bitECS set up in your project in under a minute.

Install

bun add bitecs

TypeScript Setup

bitECS is written in TypeScript and ships with full type definitions. No additional @types packages are required.

example.ts
import { createWorld, addEntity, query } from 'bitecs'

// Full type inference
const world = createWorld()
const eid: number = addEntity(world)

Recommended tsconfig.json

tsconfig.json
{
  "compilerOptions": {
    "target": "ES2020",
    "module": "ESNext",
    "moduleResolution": "bundler",
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true
  }
}
i
noUncheckedIndexedAccess adds | undefined to array index access. With SoA components, you access data by entity ID (e.g., Position.x[eid]) after calling addComponent. Enabling this option requires undefined checks on every access. Whether to enable it depends on your preference for strictness vs ergonomics.

ESM / CommonJS

bitECS supports both ESM and CommonJS imports:

ESM (recommended)
import { createWorld, addEntity, query } from 'bitecs'
CommonJS
const { createWorld, addEntity, query } = require('bitecs')