# Matter.js — card for AI agents

2D rigid body physics engine for web and game development.

Category: Game development · npm package `matter-js` · latest version 0.20.0 (checked 2026-11-01)
Install: `npm install matter-js`
License: MIT (permissive)

In your own product (generator, app, hosted service): **yes**. Permissive license: ship it inside your own product, closed or open source, and keep its license and copyright notice.

## Rules for AI agents (paste into AGENTS.md or CLAUDE.md)

## Matter.js
- Install with `npm install matter-js`. If you load it with a script tag, use a stable release from the tags, not the experimental alpha build on master.
- Start from the Getting started wiki page. Its minimal example is meant to run in both browsers and Node.js.
- When the project has its own game or render loop, follow the Running and Rendering wiki pages instead of assuming the built-in canvas renderer.
- If the simulation stutters in development, check the bundler before the physics. Webpack's default sourcemap config and Vue.js watchers are known causes (see issue #1001).
- World state serialisation needs resurrect.js. Add it explicitly before saving or restoring worlds.
- Before writing a feature from scratch, look for the matching demo in the repo's `examples` directory, then for a plugin in the wiki's List of plugins.

## What it is
- Matter.js is a 2D rigid body physics engine for the web. It is written in JavaScript by Liam Brummitt, published on npm as `matter-js`, and MIT licensed. The GitHub repository was created on 2014-02-19.
- You build a world out of bodies, composites and constraints. The engine then handles gravity, friction, restitution, collisions, sleeping and static bodies. It includes a canvas renderer, and the wiki shows how to drive the engine from your own game and rendering loops. The README says its minimal usage example should work in both browsers and Node.js.
- The README gallery points to interactive websites and games built with it, including a Google project and the Phaser game framework. It suits web developers who need 2D bodies that stack, bounce, collide and react to touch.

## Caveats
- Dev-mode tooling can slow the simulation: The README warns that bundlers and frameworks may reduce real-time performance with their default configs, especially in development modes.
- Webpack sourcemaps and Vue watchers: The README names two specific culprits: Webpack's default sourcemap config and Vue.js watchers. It points to GitHub issue #1001 for fixes, not to a setting in the library itself.
- Saving world state needs another library: World state serialisation is listed as a feature, but it requires the separate resurrect.js project.
- The master build is experimental: The README offers stable releases from the tags, and separately an "experimental" alpha build from master. Do not mix the two up when you include the script directly.
- Two dimensions only: The project describes itself as a 2D rigid body engine. Nothing in the sources mentions 3D physics.

## Numbers (AgentGid data)
- Gid Score: 55.9 (#1368 of all tools, 2 of 8 in its category)
- Used in 5 public projects set up for AI coding agents (0.1%)
- Downloads last week: 586,311 (as of 2026-11-24), +52.4% over 4 weeks
- GitHub stars: 18,674 (as of 2026-11-24)
- Last push: 2026-09-30

## Often used with
Three.js 73.5%, React Three Fiber 70.6%, React 94.1%, Framer Motion 52.9%, GSAP 52.9%, React Router 50.0%

## Checked alternatives (same job)
- Phaser: https://agentgid.com/tools/phaser/agent.md

## Links
- AgentGid page: https://agentgid.com/tools/matter-js/
- Homepage: http://brm.io/matter-js/
- Repository: https://github.com/liabru/matter-js
- Source: https://github.com/liabru/matter-js#readme
- Source: https://github.com/liabru/matter-js
- Source: https://www.npmjs.com/package/matter-js

---
AgentGid's catalog is curated: every entry was checked against the maker's official pages (registry, repository, license and pricing pages) on the date shown; a license value shows the quote it stands on wherever AgentGid has one. Usage numbers come from AgentGid's own scan of public repositories set up for AI coding agents. Claims by makers are reported, not tested by AgentGid.
